I'm trying to make a local script in StarterPlayerScripts where when you touch a tagged object it falls. The problem I'm having is that when one platform is falling I have to wait for it to finish before the next platform falls. I assume its something to do with the debounce but I don't know how I would change that.
script:
local CollectionService = game:GetService("CollectionService")
local TweenService = game:GetService("TweenService")
local localplayer = game.Players.LocalPlayer
local db = false
for _, platform in pairs(CollectionService:GetTagged("Fall")) do
local part = platform:WaitForChild("Platform")
local partpos = part.Position
part.Touched:connect(function(hit)
if db == false and hit.Parent.Name == localplayer.Name then
db = true
local partclone = part:Clone()
part:Clone()
partclone.Parent = game.Workspace
partclone.Transparency = 1
partclone.CanCollide = false
local MoveCFrame = part.CFrame * CFrame.new((0), (-1), (0))
local tweenInfo = TweenInfo.new(.2,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut,0,true,0)
local Move = TweenService:Create(part, tweenInfo,{CFrame = MoveCFrame})
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local humanoid = hit.Parent:FindFirstChildWhichIsA("Humanoid")
if(hit.Parent:FindFirstChild("Humanoid")~=nil)then
Move:Play()
Move.Completed:Wait()
partclone.Transparency = 0
partclone.Anchored = false
part.Transparency = 1
part.CanCollide = false
part.CanTouch = false
task.wait(2)
partclone:Destroy()
part.Transparency = 0
part.CanCollide = true
part.CanTouch = true
db = false
end
end
end)
end
** You are now Level 1! **