Hello! I was wondering how you would go about teleporting a player to another area of the map after a certain amount of time?
What I want is players to spawn and then after a few seconds they will be teleported to another part of the map. I am thinking I am going to do wait(30) then I will do the teleport but I am unsure of how I would do that?
Place a part on the map put it at the position you want them to goto then get the position of the part and put a script in serverscriptservice.
Put this inside of the script:
while true do
wait(30)
for _,v in pairs(game:GetService("Players"):GetPlayers()) do
if v.Character then if v.Character:FindFirstChild("HumanoidRootPart") then v.Character:FindFirstChild("HumanoidRootPart").CFrame = CFrame.new(position) end
end
end
Set position to where you want them to be teleported to.
Thank you! But I get this error 16:17:15.033 ServerScriptService.Script:6: Expected ‘end’ (to close ‘do’ at line 1), got ; did you forget to close ‘then’ at line 4? - Studio - Script:6
so with that error if you were to look there’s a simple miscount of the ends
long version
while true do
wait(30)
for _,v in pairs(game:GetService("Players"):GetPlayers()) do
if v.Character then
if v.Character:FindFirstChild("HumanoidRootPart") then
v.Character:FindFirstChild("HumanoidRootPart").CFrame = CFrame.new(position)
end
end -- missing this end in the original fix
end
end
if were to count out each if statement you would find that the if character didn’t get an end
shorten version
while true do
wait(30)
for _,v in pairs(game:GetService("Players"):GetPlayers()) do
if v.Character then if v.Character:FindFirstChild("HumanoidRootPart") then v.Character:FindFirstChild("HumanoidRootPart").CFrame = CFrame.new(position) end end
end
end
Ah ok. I thought so but their is another error? 16:27:27.476 ServerScriptService.Script:6: invalid argument #1 to ‘new’ (Vector3 expected, got nil) - Server - Script:6
SetPrimaryPartCFrame is a function that can be used on models to change it’s CFrame. player.Character:SetPrimaryPartCFrame(CFrame.new(0,0,0)) would move the player to the coordinates 0,0,0.
TP = --| Part
script.Parent.Touched:Connect(function(Hit)
if Hit.Parent:FindFirstChild("Humanoid") then
wait(30)
Hit.Parent:MoveTo(TP.Position)
end
end)
Click:
TP = --| Part
script.Parent.ClickDetector:Connect(function(Player)
wait(30)
Player.Character:MoveTo(TP.Position)
end)