#How to make Buttons work without .Touched
1 messages · Page 1 of 1 (latest)
getpartboundsinbox?
what does that do?
It gets all the parts in a specified region in the shape of a box
Raycasting is also a good method to solve your problem, as well, so I would continue to experiment with that
you could just like
use collectionservice
whats that
so you only need 1 .Touched event
its a service that lets you get all the objects with the same tag
CollectionService could work as well, yeah
Would be trickier to implement than just using a raycast, in my opinion, though
Im using raycast, but i cant get it to work
like
it doesnt print any result
i tried rotating it every way possible
what makes you think raycast is better than .touched
because .touched only works when the player is moving on the part
and i can fire raycast every set ammount of time
skill issue
i forgot how to check for the hrp without all this code
it keeps printing RayCast Had No Result
literally easier
well at least you're raycasting from the character instead of from every button
did you maybe consider putting a big invisible hitbox on top of the button where the player would be standing, instead of connecting to the button's surface which will periodically fire when moving?
You have an intriguing method of getting the players character
so i thought of that, but idk how to do that
Uh, interesting raycast direction btw
how can you manage a raycast but not know how to connect to .touched+.touchended and filter for hrp's?
You have it pointing directly out the side lol
i know
Also, there's no need for the raycast part
uh
idk :3
Just use the humanoidrootparts position as an origin with a raycast direction of Vector3.new(0, -4, 0)
ai is only 2 letters bruh of course you know how to spell that
Make sure to set the overlap params to not hit on the player as well
whats an overlap parameter
so you want to make a button
that neees ro be touched
but you don't want touched?
you can get the player's character from player.Character fyi
the ultrashit?
i want it so the player doesnt have to move
If you consider a laggy mess that takes more time debugging than it would have taken to write it manually "not bad," then yeah
yea, that's ai's stupidity
i want it so it triggers every x ammount of time
not every time the player collides with it
oh wait, I mistook overlap params for raycast params
Overlap is for sparial query
.Touched is just inefficient for this. It's much easier to just get a ray that presses a button every once in a while, that way you don't have to go through the loops of getting it to detect when your player leaves the button or not
Btw, here's a snippet of code I whipped up in like 10 seconds that you can use to see how the raycast params work
local character = script.Parent
local humRp = character.HumanoidRootPart
while task.wait() do
local rp = RaycastParams.new()
rp.FilterDescendantsInstances = character:GetChildren()
local ray = workspace:Raycast(humRp.Position, Vector3.new(0, -4, 0), rp)
if ray then
print(ray.Instance, ray.Position)
end
end