So hopefully you know those basic two-player obbies where you touch a button and the path appears, and when you get off the button, it disappears. I’ve basically accomplished that, but I’m having the problem where slight movements on the button cause the path to turn off/on.
I used both Touched/TouchEnded, and this is my code right now (in ServerScriptService)
I know that the problem is that whenever another player’s part goes off the button, the TouchEnded event fires, but I have no idea how to make a system that tracks when the entire player is off the button. I also just started coding like 2 weeks ago, so I’m not very experienced.
Would love some help if anyone knows how to solve this, thanks!
Debounce helps but probably not well in your case since it’s not really a timer type event.
You may want to do something like raycasting straight down from the player’s Humanoid Root Part and checking to see if the RaycastResult returns the name of the button Part (let’s just assume you’ve named it “Button” for now).
This would have a bit of an issue if the player was just over halfway off the Button but the raycast didn’t ‘see’ it, so you may want to put a BlockMesh in the Button and change the scale so the Button appears smaller than it actually is so the raycast will ‘see’ it farther out. You’d have to play with the Scale until you get the size that works for you.
Start with the Touched event to turn the path CanCollide true, but don’t use TouchEnded, fire the raycast every .1 seconds or so to see if the player left the Button. If the raycast result doesn’t see a part named ‘Button’ then the player’s left the button, and turn the path CanCollide false.
No.
Like I said, it’s really buggy.
You can have multiple Touched and TouchEnded firings when a player walks across the button.
When you have more than one player it only gets worse.
Look at the create.roblox.com site and search raycasting. There are very good tutorials and information there (that’s where the Debounce link I posted above came from, although I see you haven’t clicked on that yet).
I looked at raycasting a couple years ago, and the documentation helped better than most of their tutorials.