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

Game teleports players in studio, but doesn't teleport them in game?

I made a game script but the players don't get teleported to game? Please help! The script is the part that doesn't work. Code doesn't get executed after the teleport script

					local MapList = Maps:GetChildren()
					local SelectedIndex = math.random(1,#MapList)
					local ChosenMap = MapList[SelectedIndex]:Clone()
					ChosenMap.Parent = workspace
					wait(10)
					Sheriffs = Players:GetPlayers() -- Gets all sheriffs
					local PlayerIndex = math.random(1,#Sheriffs)
					local JuggernautPlr = Sheriffs[PlayerIndex] 
					table.remove(Sheriffs,findIndex(Sheriffs,JuggernautPlr))
for i,v in pairs(Sheriffs) do 
						local NewGun = Gun:Clone()
						NewGun.Parent = v.Backpack
						local GameTag = Instance.new("StringValue") -- Used to see if they are in game
						GameTag.Name = "GameTag"
						GameTag.Parent = v.Character
						local Humanoid = v.Character:WaitForChild("Humanoid")
						local SpawnIndex = math.random(1,#AllSpawns)
						local ChosenSpawn = AllSpawns[SpawnIndex]
						Humanoid:MoveTo(ChosenSpawn.Position+Vector3.new(0,3,0)) -- This doesn't work!
						table.remove(AllSpawns,findIndex(AllSpawns,ChosenSpawn))
					end

5 comments

0

Is it in a local script or a normal script?

0

normal script

0

Do not use :MoveTo(), instead teleport the HumanoidRootPart to the area you want to go to, also add a +Vector3.new(0,5,0) so players don't get stuck.

0

Nope, still didn't work in game.

0

It works in studio, but in game it doesn't work.

1 answer

you should use; v.Character.HumanoidRootPart.CFrame = CFrame.new(ChosenSpawn.CFrame)+CFrame.new(0,3,0);

however;keep in mind that there could be other factors that influenced it to not work; such as v.Character being nil, so you might want to use defensive programming to avoid errors;

in case it doesn't work again, press f9 to check the developer console for errors

2 comments

0

It still doesn't work, but the developer console doesn't output any errors..?

0

try debugging with print() to see if statements are being reached and executed

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