Teleportation Not Working

I am making a basic hide and seek game for practice. I make the first few lines of a script and I see if it works. No errors. Just does not work.

local players = game.Workspace:GetChildren()

if game:GetService("StarterGui").IntermissionScreenGui.IntermissionTextLabel.Text == 0 then
	for i, v in pairs(players) do
		if v:IsA("Model") then
			local humanoidrootpart = v:FindFirstChild("HumanoidRootPart")
					if game.workspace.MapValue.Value == "City" then
				humanoidrootpart.CFrame = game.Workspace.CitySpawnLocation
			end
		end
	end
end
1 Like

So I’m not sure if this is the problem but texts are Strings and you are checking if the text is equal to an Integer simply because you forgot the quotation "0".

if game:GetService("StarterGui").IntermissionScreenGui.IntermissionTextLabel.Text == "0" then
	for i, v in pairs(players) do
		if v:IsA("Model") then
			local humanoidrootpart = v:FindFirstChild("HumanoidRootPart")
					if game.workspace.MapValue.Value == "City" then
				humanoidrootpart.CFrame = game.Workspace.CitySpawnLocation
			end
		end
	end
end

Not sure if that’s the mistake, if the error is still happening make sure to let me know.

1 Like

not really sure but shouldn’t it be

humanoidrootpart.CFrame = game.Workspace.CitySpawnLocation.CFrame

?

oh yeah, also use PlayerGui rather then ScreenGui

1 Like

Thanks a lot. There is another problem though and if you do not mind, the problem is that line 4 is not giving me the humanoidrootparts of all characters in the game. I did not include this because I did not want to make people do all the work for me but I have been working on this other issue for a long time to no avail. So this really is my only option.

1 Like

Thanks, I forgot about that. Unfortunately, the developer forum does not allow me to give more than one solution to people so I just chose a different one. I am still confused on why line 4 does not give me the humanoidrootparts of all characters in the game though… I did not include it because I wanted to keep this thread short and not use up people’s time and labor but I do not know what the problem is.

Edit: I fixed it. The script was running too fast since I had the text automatically set to 0 so that each time I test the script I would not have to wait but that ended up backfiring to where it starts too fast before the player loads.

1 Like

Try to do this Instead :

for _,v in pairs(game.Players:GetPlayers()) do
local char = v.Character
local humanoidrootpart = char:FindFirstChild("HumanoidRootPart")
	if game.workspace.MapValue.Value == "City" then
		humanoidrootpart.CFrame = game.Workspace.CitySpawnLocation.CFrame
	end
end

Change your other loop to this one.

1 Like

Does not seem to work. Is there is a piece of information I am leaving out here?

Edit: I fixed it. The script was running too fast since I had the text automatically set to 0 so that each time I test the script I would not have to wait but that ended up backfiring to where it starts too fast before the player loads.

1 Like