Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Script is not working?? Players don't teleport to the location

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

1 comment

0

Try using :MoveTo(Vector3Pos) on the character rather than the root part. See if anything changes.

1 answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.