function TeleportPlayerToMap()
print("Teleport function works")
for i, plr in pairs(AllPlayers) do
print(plr.Name)
if plr:FindFirstChild("Settings").AFK.Value ~= true then
print(plr.Name.."is not AFK")
if plr ~= nil then
if plr.Character ~= nil then
if plr.Character:FindFirstChild("Humanoid").Health ~= 0 then
local spawns = CurrentMap:FindFirstChild(MapSelected.Value):FindFirstChild("Spawns"):GetChildren()
if spawns ~= nil then
local ransp = spawns[math.random(1,#spawns)].CFrame + Vector3.new(0,3,0)
plr.Character.HumanoidRootPart.CFrame = ransp
wait()
end
end
end
end
end
end
print("Teleport complete")
end
So for some reason this script prints "Teleport function works" and "Teleport complete", however it does not teleport the player to the spawns on the map.

5 comments
Is this a Server Script? If it is, you can't call a player's character from the server the way you're attempting. Also the Teleport Complete is being printed since it's outside the function
This is a server script, and I didn't notice that it was outside the function mb
I'm working on a response now, can you tell me what the "CurrentMap" is? I can guess what allplayers is but idk if currentmap is a model or...?
"CurrentMap" is a string value inside of workspace that allows me to have the name of the map that was picked
Wait is this from a youtuber's minigame tutorial?