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.

3 comments
Can you link the dev forum post?
https://devforum.roblox.com/t/one-way-platforms/272905 here you go
Also, I tried adding debounce because I was desperate, but to no avail