I'm attempting to make a one-way platformer. For a better explanation, Mario is a very good example of this. What I'm trying to attempt is the floating stone platforms in Mario; you can jump right through them and stand on them. I attempted to do this, but it was extremely glitchy. Here is the script:
01 | local Detector = script.Parent.Detector |
02 | local Platform = script.Parent |
03 |
04 | Detector.Touched:Connect( function (object) |
05 | if object.Parent:WaitForChild( "Humanoid" ) then |
06 | print ( true ) |
07 | Platform.CanCollide = true |
08 | end |
09 | end ) |
10 |
11 | Detector.TouchEnded:Connect( function (object) |
12 | if object.Parent:WaitForChild( "Humanoid" ) then |
13 | print ( false ) |
14 | Platform.CanCollide = false |
15 | end |
16 | end ) |
I used a dev forum answer, and as the person said, it was very glitchy. Any idea how to make this better?
Any help is appreciated.
First off, .Touched and .TouchEnded in a mix, is really buggy to use, so just use a debounce, so the effects would appear.
01 | local Detector = script.Parent.Detector |
02 | local Platform = script.Parent |
03 | local Debounce = true |
04 | local Switch = false |
05 |
06 | Detector.Touched:Connect( function (object) |
07 | if object.Parent:WaitForChild( "Humanoid" ) and Debounce and then |
08 | Debounce = false |
09 | print ( true ) |
10 | Platform.CanCollide = true |
11 | end |
12 | end ) |
13 |
14 | Detector.TouchEnded:Connect( function (object) |
15 | if object.Parent:WaitForChild( "Humanoid" ) and not Debounce then |
Try making a switch effect with .Touched and .TouchEnded event, and if this doesn't work you will hopefully find an answer,