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

How to make the players character.Humanoid.RootPart teleport to a chosen place?

Asked by 3 years ago
inround.Changed:Connect(function()
    if inround.Value == true then
        for i, plr in pairs(game.Players:GetChildren()) do
            local char = plr.Character.Humanoid.RootPart
            if forestmapworkspace == true then
                local tpparts = math.random(1, #maps:WaitForChild("Forest"):WaitForChild("TPParts"):GetChildren())
                local parts = maps:WaitForChild("Maps"):WaitForChild("Forest"):WaitForChild("TPParts").CFrame
                if tpparts == 1 then
                    char.CFrame = parts:WaitForChild("TPPart1").CFrame
                elseif tpparts == 2 then
                    char.CFrame = parts:WaitForChild("TPPart2").CFrame
                elseif tpparts == 3 then
                    char.CFrame = parts:WaitForChild("TPPart3").CFrame
                elseif tpparts == 4 then
                    char.CFrame = parts:WaitForChild("TPPart4").CFrame
                elseif tpparts == 5 then
                    char.CFrame = parts:WaitForChild("TPPart5").CFrame
                elseif tpparts == 6 then
                    char.CFrame = parts:WaitForChild("TPPart6").CFrame
                elseif tpparts == 7 then
                    char.CFrame = parts:WaitForChild("TPPart7").CFrame
                elseif tpparts == 8 then
                    char.CFrame = parts:WaitForChild("TPPart8").CFrame
                elseif tpparts == 9 then
                    char.CFrame = parts:WaitForChild("TPPart9").CFrame
                elseif tpparts == 10 then
                    char.CFrame = parts:WaitForChild("TPPart10").CFrame
                elseif tpparts == 11 then
                    char.CFrame = parts:WaitForChild("TPPart11").CFrame
                elseif tpparts == 12 then
                    char.CFrame = parts:WaitForChild("TPPart12").CFrame
                else
                    print("Doesn't work")
                end


            elseif mountainsmapworkspace == true then
                local parts = maps:WaitForChild("Maps"):WaitForChild("Mountains"):WaitForChild("spawnparts")
                local tpparts = math.random(1, #maps:WaitForChild("Mountains"):WaitForChild("spawnparts"):GetChildren())
                if tpparts == 1 then
                    char.Humanoid.RootPart.CFrame = parts:WaitForChild("SpawnPart1").CFrame 
                elseif tpparts == 2 then
                    char.Humanoid.RootPart.CFrame = parts:WaitForChild("SpawnPart2").CFrame 
                elseif tpparts == 3 then
                    char.Humanoid.RootPart.CFrame = parts:WaitForChild("SpawnPart3").CFrame 
                elseif tpparts == 4 then
                    char.Humanoid.RootPart.CFrame = parts:WaitForChild("SpawnPart4").CFrame 
                elseif tpparts == 5 then
                    char.Humanoid.RootPart.CFrame = parts:WaitForChild("SpawnPart5").CFrame 
                elseif tpparts == 6 then
                    char.Humanoid.RootPart.CFrame = parts:WaitForChild("SpawnPart6").CFrame 
                elseif tpparts == 7 then
                    char.Humanoid.RootPart.CFrame = parts:WaitForChild("SpawnPart7").CFrame 
                elseif tpparts == 8 then
                    char.Humanoid.RootPart.CFrame = parts:WaitForChild("SpawnPart8").CFrame 
                elseif tpparts == 9 then
                    char.Humanoid.RootPart.CFrame = parts:WaitForChild("SpawnPart9").CFrame 
                elseif tpparts == 10 then
                    char.Humanoid.RootPart.CFrame = parts:WaitForChild("SpawnPart10").CFrame 
                elseif tpparts == 11 then
                    char.Humanoid.RootPart.CFrame = parts:WaitForChild("SpawnPart11").CFrame 
                end
            else
                print("Doesn't work")
            end
        end
    elseif inround.Value == false then
        for i, plr in pairs(game.Players:GetChildren()) do
            local char = plr.Character.Humanoid.RootPart
            local thespawnrandom = math.random(1, #game.Workspace.Lobby.Spawns:GetChildren())
            local partspawn = game.Workspace.Lobby.Spawns
            if thespawnrandom == 1 then
                char.CFrame = partspawn.SpawnLocation1.CFrame
            elseif thespawnrandom == 2 then
                char.CFrame = partspawn.SpawnLocation2.CFrame
            elseif thespawnrandom == 3 then
                char.CFrame = partspawn.SpawnLocation3.CFrame
            elseif thespawnrandom == 4 then
                char.CFrame = partspawn.SpawnLocation4.CFrame
            elseif thespawnrandom == 5 then
                char.CFrame = partspawn.SpawnLocation5.CFrame
            else
                print("Doesn't work")
            end

        end
    end
end)

This is what I have so far but it doesn't work.

2 answers

Log in to vote
0
Answered by 3 years ago

the HumanoidRootPart isn't parented to the Humanoid object, but to the character model. try plr.Character.HumanoidRootPart

0
Thanks for helping me out! mymatevince1215 9 — 2y
Ad
Log in to vote
0
Answered by 3 years ago

try and use this instead of 'char.Cframe.....'

Player.Character.HumanoidRootPart.Position = game.Workspace.PARTNAME.Position

let me know how it goes and if it works

0
It sadly doesn't work. I changed it from .CFrame to .Position but it still doesn't teleport all players/ mymatevince1215 9 — 3y
0
It sadly doesn't work. I changed it from .CFrame to .Position but it still doesn't teleport all players/ mymatevince1215 9 — 3y
0
you need to add player.character.humanoid because the root part isnt parents with the humanoid itself, its parented in the model Helloimpets 17 — 3y

Answer this question