Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago
Edited 4 years ago

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
0
Is it in a local script or a normal script? IceAndNull 142 — 4y
0
normal script ayeayeCommsta 24 — 4y
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. Cooltech90 -3 — 4y
0
Nope, still didn't work in game. ayeayeCommsta 24 — 4y
0
It works in studio, but in game it doesn't work. ayeayeCommsta 24 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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

0
It still doesn't work, but the developer console doesn't output any errors..? ayeayeCommsta 24 — 4y
0
try debugging with print() to see if statements are being reached and executed User#23252 26 — 4y
Ad

Answer this question