Vanishing Platform Lag

Hello! I’m having a problem with my obby’s vanishing platforms lagging for other players.
Sometimes, the platform will turn invisible and the players can still jump on it and get through.
This has been a noticeable bug for several play testers. The code is simple… here it is below.

local platform = script.Parent

function show()
    platform.Transparency = 0
    platform.CanCollide = true
end

function hide()
    platform.Transparency = 0.6
    platform.CanCollide = false
end

while true do
    show()
    wait(3)
    hide()
    wait(2)
end

How can I fix this? Thank you.

1 Like

I honestly don’t know but try adding a wait() to the while line

Try making it a localscript under starterplayerscripts. Probably server-client delay is causing issues.

2 Likes

Maybe add something like this to the loop:

If platform.Transparency == 0 then
   platform.CanCollide = true
Else
   platform.CanCollide = false
End

I assume this would still lead to problems with syncing though? You would see other players jumping on invisible platforms, for example, if Player B joins a few seconds after Player A (or lags).

Yes, that would be a problem but the experience for local (laggy) players will be much better, as the code is running on their machine.