Alright, so I have tried asking this before probably a year ago. I cannot figure out why this script does not work. I've tried working around it so many ways so far and I can't seem to find out what is wrong (even after taking a while away from this and then rewriting the script).
I am trying to teleport the players 3 seconds after the map spawns in:
-- Inside the PlayerAdded function
if chosen.Value ~= "" then
mapSelected = true
spawnMap()
wait(3)
movePlayers()
return
end
But here are the two functions, spawnMap() and movePlayers() :
function spawnMap()
local mapName = workspace.CurrentMap:WaitForChild("ChosenMap") -- A StringValue
local map = game.ReplicatedStorage.Maps:FindFirstChild(mapName.Value)
if map.Name == mapName.Value and mapSelected then
wait()
local newmap = map:Clone()
newmap.Parent = workspace
spawnpoint.Parent = workspace
spawnpoint.Position = workspace.Spawn.Position -- Temporary position for testing
end
end
function movePlayers()
for i,v in pairs(players) do
v.Character.HumanoidRootPart.CFrame = spawnpoint * CFrame.new(math.random(5,10),0,math.random(5,10))
end
I am seeing no errors as of now, but players do not teleport. I've also tried:
v.Character:FindFirstChild("HumanoidRootPart").CFrame = spawnpoint * CFrame.new(math.random(5,10),0,math.random(5,10))

1 comment
MoveTo is the function to make a player walk if I'm not mistaken.