:PivotTo and :SetPrimaryPartCFrame makes character behave weirdly

Hellooooooo!!
I am making a game, and for a cutscene… well, i need the player to be at a specific place so the animation will play correctly.

(I cannot list video because file attachment megabyte stufffff, but just imagine me flying sideways when i walk sideways and jump)

To teleport the player, I use :PivotTo. Or, :SetPrimaryPartCFrame.
This is a local script in StarterCharacterScripts. And this is how I worded it;

**blah blah blah, getting local player character stuff..**

character:PivotTo(cutscene.CutsceneTrigger.CFrame)

honestly, i ruin everything i touch but i dont know how i ruined something so simple.

Any help is appreciated.

You might have the CutsceneTrigger part in a bad spot but if you don’t this should work to acheive the desired result. Make sure that the CutsceneTrigger part is anchored and uncollideable(seperate from CanTouch and CanQuery if this part triggers cutscenes when touched).

character.HumanoidRootPart.CFrame = cutscene.CutsceneTrigger.CFrame

Yess… i am on my phone, but i will tell you all the details.

Cutscene trigger is a basepart which is scaled to fit a hallway, which makes the pivot point right in the center… the part has no collision, is anchored, and is transparent… the part triggers with a local script in StarterCharacterScripts

Also… isnt this code the same thing as SetPrimaryPartCFrame…?

SetPrimaryPartCFrame along with GetPrimaryPartCFrame are Deprecated, PivotTo and GetPivot are the succesors (or the newer variants) of this system.

You can still have a functional SetPrimaryPartCFrame but you would just be moving the Actual PrimaryPart

Model.PrimaryPart.CFrame = SomeCFrame -- SetPrimaryPartCFrame

Unlike SetPrimaryPartCFrame, PivotTo can move the Model without a PrimaryPart, Its recommended you still have one so the CFrame is centered around the Model

1 Like

Yes… i said in my post i used setprimary and pivotto… they had the same results… is it possible that moving the character in a local script is the reason why it is not working?

That’s because they are pretty much are the same thing, Even documentation states as such:

This function has been superseded by PVInstance:PivotTo() which acts as a more performant replacement and does not change your code’s behavior. Use PVInstance:PivotTo() for new work and migrate your existing Model:SetPrimaryPartCFrame() calls when convenient.

Source

I’ll look at these topics later… i need to go the bed. See you tomorrow

I would try to set it on the server rather than the client, I havent had issues with pivotto functionalities but then again I never used it on a player and on the client

This seems to work in studio at least.

SpawnToCutsceneTest.rbxl (42.0 KB)
image
image

local dst = game.Workspace:WaitForChild("Destination"):GetPivot()
script.Parent.Touched:Connect(function(part)
	local player = game.Players:GetPlayerFromCharacter(part.Parent)
	if player and player == game.Players.LocalPlayer then
		part.Parent:PivotTo(dst)
	end
end)
1 Like

It seems one of your solutions have something to do with the script being a server script… I will do this and check back on you later to mark solution. (IF it works)

Edit: I should also say that I teleport the player TWICE. One for the animation beginning, then another to spawn more forward

Ohhhhhhhhhh… i figured out the problem… i had the humanoidRootPart anchored when the cutscene played so the animation would be correct… but now i have another problemmmmm… how will i stop the humanoid from moving?

You could set its humanoid.WalkSpeed to 0 and JumpPower to 0 and AutoRotate to false

Quote beneath is how OP solved the original problem!

Is the AutoRotate property in the humanoid?

Nevermind. It works. Thank you!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.