PartToTpTo = workspace.Part
while true do
wait(30)
for integer, player in next, game:GetService("Players"):GetPlayers() do
local backPosition = player.Character:GetPrimaryPartCFrame()
player.Character:MoveTo(PartToTpTo.Position)
delay(150, function()
player.Character:MoveTo(backPosition)
end
end
wait(150)
end
Explanation:
Use the while keyword to loop until an error or the break keyword appears. Use the for keyword to loop once. When you've got all the players in the for-loop: Assign a local variable to capture their current position to use it later so you can teleport them back. Use the MoveTo method to move the character model to a position. In this case, we use the part's position. Use the delay function to make it yield (wait) an amount of seconds and then fire another function without making the script yield (wait). Use another wait function to delay the next loop's start and so that you wait for the players to teleport back. In the next start, after the players have teleported back, it will wait 30 seconds again and redo the whole thing again.
1 comment
i wz gonna ask