Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Unsuccessful One way Platforms?

Asked by 4 years ago

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:

local Detector = script.Parent.Detector
local Platform = script.Parent

Detector.Touched:Connect(function(object)
    if object.Parent:WaitForChild("Humanoid") then 
        print(true)
        Platform.CanCollide = true  
    end
end)

Detector.TouchEnded:Connect(function(object)
    if object.Parent:WaitForChild("Humanoid") then 
        print(false) 
        Platform.CanCollide = false
    end
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.

0
Can you link the dev forum post? AwesomeUniverseYT 56 — 4y
0
Also, I tried adding debounce because I was desperate, but to no avail Daemonophobiaa 37 — 4y

1 answer

Log in to vote
0
Answered by
xXLuka_XD 103
4 years ago

First off, .Touched and .TouchEnded in a mix, is really buggy to use, so just use a debounce, so the effects would appear.

local Detector = script.Parent.Detector
local Platform = script.Parent
local Debounce = true
local Switch = false

    Detector.Touched:Connect(function(object)
        if object.Parent:WaitForChild("Humanoid") and Debounce and then
                Debounce = false
            print(true)
            Platform.CanCollide = true 
        end
    end)

    Detector.TouchEnded:Connect(function(object)
        if object.Parent:WaitForChild("Humanoid") and not Debounce then
            print(false)
            Platform.CanCollide = false
                wait(1.2)
                Debounce = true
        end
    end)

Try making a switch effect with .Touched and .TouchEnded event, and if this doesn't work you will hopefully find an answer,

0
Still kind of wonky but the closest to being fixed. Thanks :) Daemonophobiaa 37 — 4y
Ad

Answer this question