The problem with your script was the fact that there was no way to prevent the script from firing again once it touched another part; the wait() at the end of the script just makes the script wait before ending it, so multiple limbs could come into contact with the buttons and cause the script to fire multiple times, which results in an endless loop of teleportation.
To prevent this, add "script.disabled = true" to the script like this:
script.Parent.Touched:Connect(function(part)
local humanoid = part.Parent:FindFirstChild("Humanoid")
local button1 = script.Parent
local button2 = workspace["TelePart"]
if humanoid then
part.Parent.HumanoidRootPart.CFrame = CFrame.new(button1.Position)
button2.Script.Disabled = true
script.Disabled = true
wait(3)
button2.Script.Disabled = false
script.Disabled = false
end
end)
This also disables any extra teleport scripts (such as one located in the part you're teleporting the players to) to prevent the script from teleporting the player back to the original part. If you don't have any extra scripts, remove these lines
button2.Script.Disabled = true
and
button2.Script.Disabled = false
2 comments
Have you tried disabling the script for a certain period of time? It looks like it's running each time a part touches the scripts parent, which means any time a single part from the player touches the brick, the script runs regardless of previous limitations.
is there a script that disables the whole script for a period of time if the player activates it? i tried deactivating it by putting a wait which didn't work