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

How do I stop the Humanoid from getting stuck in the SpawnLocation?

Asked by 4 years ago

I have this code where when I choose a team it teleports to that team's spawn location, but when it teleports, the humanoid gets stuck in the spawn location.

local player = game.Players.LocalPlayer
script.Parent.Parent.Enabled = true
script.Parent.MouseButton1Click:Connect(function()
    player.Team = game.Teams.Citizen
    script.Parent.Parent.Enabled = false
    player.Character.HumanoidRootPart.CFrame = CFrame.new(game.Workspace.citizen.Position)
end)

How do I fix this problem?

1 answer

Log in to vote
0
Answered by 4 years ago

Try moving the player upwards, because if you set the player's position to the spawn points position, and if the spawn is on the ground, that means half the player's body too will be underground.

    player.Character.HumanoidRootPart.CFrame = CFrame.new(game.Workspace.citizen.Position + vector3.new(0, 10, 0))

Ad

Answer this question