Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Don't Know why this PrimaryPart rotation isn't working?

So the problem is that I am trying to rotate the model by its primary part by 90 degress but no matter what I change or try differently, it continues to weld in the exact same position every time.

local Staffs = game.ServerScriptService.StaffStuff.BackStaffs:Clone()
	Staffs.Parent = player.Character
	Staffs:SetPrimaryPartCFrame(player.Character.UpperTorso.CFrame)

local cframe = Staffs.PrimaryPart.CFrame
	Staffs:SetPrimaryPartCFrame(cframe * CFrame.Angles(0, math.rad(90), 0))

local welder = Instance.new("Weld")
	welder.Parent = Staffs.Main
	welder.Part0 = Staffs.Main
	welder.Part1 = player.Character.UpperTorso

2 comments

0

pi/2 radians is 90 degrees so don't waste time doing math.rad(90)

0

That isn't the problem though, The issue is that the model isn't rotating at all.

1 answer

#####Preface: You should store game assets in ServerStorage or ReplicatedStorage. Only use ServerScriptService for storing Scripts meant to run.


You had not set C0 or C1 to offset the PrimaryPart to the UpperTorso. You will need to use the relative CFrame of the UpperTorso to the PrimaryPart set using object space.

local welder = Instance.new("Weld")

welder.C1 = Staffs.Main.CFrame:toObjectSpace(player.Character.UpperTorso.CFrame)

welder.Part0 =	player.Character.UpperTorso
welder.Part1 = Staffs.Main

welder.Parent = game.JointService

This should set the Weld correctly with the CFrame you had set. I assume the issue you had could be seen in one of the references I provide down below.

######If I missed something or you need something explained let me know.


###References:

This is just for the visual:

This discussion is preserved as it was. New answers, comments, and votes are closed.