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

Why does this script delay a part by one second?

Asked by 7 years ago

It works at first but then 1 second later it teleports, even when I'm not touching it?

local table = {
    "Player1",
    "",
    ""
}
cooldown = false
place = workspace.ToSpawn
script.Parent.Touched:connect(function(hit)
    if game.Players:GetPlayerFromCharacter(hit.Parent) and (not cooldown) then
        cooldown = true
        local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
        local chr = plr.Character
        for i,v in pairs(table) do
            if plr.Name == v then
                script.Parent.CanCollide = false
                script.Parent.Transparency = .3
                wait(1)
                script.Parent.CanCollide = true
                script.Parent.Transparency = 0
                cooldown = false
            else
                chr:WaitForChild("HumanoidRootPart")
                chr.HumanoidRootPart.CFrame = place.CFrame + Vector3.new(0,2,0)
                cooldown = false
            end
        end
    end
end)

Not sure at all, is it waiting then going back to it?

0
Nothing seems wrong with your script, its probably just the server registering the hit a little bit late. User#17125 0 — 7y
0
connect is deprecated. Use Connect. Thundermaker300 554 — 7y
0
thunder pls don't lose sleep over a dumb capitalization quirk cabbler 1942 — 7y

1 answer

Log in to vote
0
Answered by
lukedm 0
7 years ago

In line 17 you have a wait for one second, to reduce the time, make it 0.0000001 seconds

Ad

Answer this question