Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why does this script delay a part by one second?

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?

3 comments

0

Nothing seems wrong with your script, its probably just the server registering the hit a little bit late.

0

connect is deprecated. Use Connect.

0

thunder pls don't lose sleep over a dumb capitalization quirk

1 answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.