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

How To Rotate And Adjust CFrame?

Hi scripters, I've been wanting to weld a knife on the back of my character for a long time now so today I actually tried to do this however im still finding out what the proper rotation of the knife would be and how would I adjust the CFrame so it's on the back of my character and not in my character...

Here what I have right now: https://imgur.com/a/mVNrkvi

What I want: https://imgur.com/a/s5KYD82

Heres the code:

	local melee = game.Workspace.Weapons[PLAYER_KNIFE.Name]:Clone()
	melee.Parent = game.Players.LocalPlayer.Character
	melee.CFrame = game.Players.LocalPlayer.Character.UpperTorso.CFrame * CFrame.Angles(0,math.pi,0)
	local weldconstraint = Instance.new("WeldConstraint")
	weldconstraint.Part0 = game.Players.LocalPlayer.Character.UpperTorso
	weldconstraint.Part1 = melee
	weldconstraint.Parent = melee
	--[[
		 |  this is where the issue is..
		V
	--]]
	melee.Rotation = Vector3.new(45,45,0)
	melee.CFrame = CFrame.new(1,0,0)

1 answer

✓ Accepted answer

Not entirely sure why you are using math.pi.

To position and rotate using CFrame you can use this:

CFrame.new(0,0,0) * CFrame.Angles(math.rad(0), math.rad(0), math.rad(0))

-- math.rad makes rotation A LOT easier.

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