I'm trying to make a platformer game with all sorts of obstacles. I figure the best thing to do would be to make all of the obstacles local, so that way players won't have to take turns. My issue is that, with how I'm executing it, you can only perform the affects of one platform at a time. Might sound vague, so let me explain with a simple example:
local plats = game.Workspace:waitForChild("breakPlatorms"):GetChildren() -- a model of the platforms that was cloned locally into the player's Workspace beforehand
local debounce = 0
for i, v in next, plats do
v.Touched:Connect(function(part)
if part.Parent:findFirstChild("Humanoid") == nil then return end
if debounce == 0 then
debounce = 1
v.Transparency = 1
v.CanCollide = false
wait(3)
v.Transparency = 0
v.CanCollide = true
debounce = 0
end
end)
end
Now this technically works, but my issue is that if another platform is less than 3 seconds away, it won't do what it's supposed to do until the actions of the first platform are completed, which takes 3 seconds. I understand that with this code setup, you can only do one thing at a time. I'm not sure how to efficiently make this happen, since server Scripts can't really interact with LocalParts. Would I make a Remove Event for every single one or a Module Script or something else?

1 comment
This code works, thank you! If possible though, could you please explain it a bit? I'm not quite sure what I'm looking at.