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

Script is not working?? Players don't teleport to the location

Asked by 5 years ago

Im trying to get the players teleported to the certain location There is no error given in the console

01local spawnLocation = game.Workspace:WaitForChild("Brick")
02local loadedSpawnLocation = spawnLocation:GetChildren()
03 
04 
05for i, v in pairs (game.Players:GetPlayers()) do
06 
07        local character = v.Character:FindFirstChild("HumanoidRootPart")
08        wait(2)
09        character.CFrame = loadedSpawnLocation.CFrame
10    end

Thanks in advance

0
Try using :MoveTo(Vector3Pos) on the character rather than the root part. See if anything changes. Asentis 17 — 5y

1 answer

Log in to vote
0
Answered by
MVDawn 2
5 years ago

I believe this works, At least I hope so, as it works in my studio build. (an older version of the roblox studio)

1local spawnLocation = game.Workspace:WaitForChild("Brick")
2local people = game.Players:GetPlayers()
3for i = 1,#people do
4    people[i].Character.HumanoidRootPart.CFrame = spawnLocation.CFrame
5end

Explanation:

1local people = game.Players:GetPlayers()

put this before the teleportation, as every-time the script for teleporting is ran, it checks all the players on the game at the time the script is run.

1for i = 1,#people do

keeps checking for people to do the loop until theres none more to teleport.

1people[i].Character.HumanoidRootPart.CFrame = spawnLocation.CFrame

teleports the person's RootPart CFrame to the spawnLocation CFrame.

Ad

Answer this question