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

local spawnLocation = game.Workspace:WaitForChild("Brick")
local loadedSpawnLocation = spawnLocation:GetChildren()


for i, v in pairs (game.Players:GetPlayers()) do

        local character = v.Character:FindFirstChild("HumanoidRootPart")
        wait(2)
        character.CFrame = loadedSpawnLocation.CFrame
    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)

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

Explanation:

local 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.

for i = 1,#people do

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

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

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

Ad

Answer this question