I have a script that doesn't work no matter how I code it. Can someone help me with this?
local players = game.Players:GetPlayers() local randomPlayer = math.random(1, #players) while true do randomPlayer.Character:MoveTo(Vector3.new(44.6,-13.5,-50.4)) wait(3) end
I'm not really a fan of :MoveTo()
. I prefer to edit their position manually.
here's how I teleport players:
while true do randomPlayer.Character:SetPrimaryPartCFrame(CFrame.new(Vector3.new(44.6, -13.5, -50.4))) wait(3) end
local randomPlayer = math.random(1, #players)
This will just return a number not the player
What you need is
while wait(3) do Player = game.Players:GetPlayers() selectedPlayer = Player[math.random(0, #Player)] workspace:WaitForChild(selectedPlayer.Name):SetPrimaryPartCFrame(CFrame.new(44.6, -13.5, -50.4) end