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

How do you teleport the local player in a local script?

Asked by
TNTeon -1
6 years ago

This is my code but I don't know why it is not working

if game.Players.NumPlayers < 4 then

local spawns = game.workspace.Wait:WaitForChild('waiting'):GetChildren() for _, player in pairs(game.Players:GetPlayers()) do if player and #spawns > 0 then local head = player.Character:WaitForChild('Head') local allspawns = math.random(1, #spawns) local randomspawn = spawns[allspawns] if randomspawn and head then head.CFrame = CFrame.new(randomspawn.Position + Vector3.new(0,2,0)) end end end end

0
Please use a code block for your script. RGRage 45 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Note: Create a local script in StaterPack or StarterGui.

I've tried to base this of the code example you gave above.

local player = game.Players.LocalPlayer
local spawns = game.workspace.Wait:WaitForChild('waiting'):GetChildren()

local head = player.Character:WaitForChild('Head') 
local allspawns = math.random(1, #spawns) 
local randomspawn = spawns[allspawns] 

if randomspawn and head then head.CFrame = CFrame.new(randomspawn.Position + Vector3.new(0, 2, 0)) 

    end 
end 

0
Let me know if you encounter and problems. StoleYourClothes 105 — 6y
Ad

Answer this question