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

Why isn't the player rotating?

Asked by 4 years ago
Edited 4 years ago

I made a script to teleport the player, anchor the player in place, and rotate him. It is a normal script, and it is in the workspace.

`game.Players.PlayerAdded:Connect(function(player)

player.CharacterAdded:Connect(function(char)

    char:GetPropertyChangedSignal("Parent"):Wait()

    wait()

    --char.HumanoidRootPart.CFrame = CFrame.new(-90.449, 9.105, 3.904)

    char.HumanoidRootPart.CFrame = CFrame.new(-112.32, 11.758, -25.56)

    char.HumanoidRootPart.Anchored = true
    char.Animate.Disabled = true

    char.CFrame = char.CFrame * CFrame.Angles(0, math.rad(90), 0)
end)

end)`

1 answer

Log in to vote
0
Answered by 4 years ago

I believe the reason why your script is not working is that you're waiting for the Parent property of the character to change. I'm not exactly sure why you want to do that, so I'm just going to give you a solution without that. Perhaps you wanted to use that to wait for the player to die, but in that case, you could just use the Died event of humanoid instead.

Another reason as to why this doesn't work is because you're trying to set the CFrame of the character model, not the primary part (humanoid root part). Regardless, it's much better to use SetPrimaryPartCFrame. You are also anchoring the HumanoidRootPart which stops the player from moving at all.

Make sure this is a server script, so we can access the player more easily.

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        wait(0.1) --Make sure to wait atleast 0.1 seconds so the character can fully load in and not set our CFrame to the origin on spawn
        char:SetPrimaryPartCFrame(CFrame.new(-112.32, 11.758, -25.56))
        char:SetPrimaryPartCFrame(char:GetPrimaryPartCFrame() * CFrame.Angles(0, math.rad(90), 0))
    end)
end)

If you have any questions, please comment below, also please mark this question as the answer if it answered your question.

Ad

Answer this question