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

How to do Part Rotation?

I am making a character morph script, and it involves a part being rotated around the head, but my code doesn't seem to rotate the part. Could someone check my script and see what's wrong with it?

	local harr = Instance.new("Hat", plr)
	harr.AttachmentPos = Vector3.new(0.009, -0.2, -0.01)
	local haandl = Instance.new("Part", harr)
	haandl.Name = "Handle"
	haandl.Size = Vector3.new(1.42, 0.95, 1.8)
	haandl.CanCollide = false
	haandl.Anchored = false
	haandl.Position = Vector3.new(7.331, 5.096, -44.221)
	haandl.Rotation = Vector3.new(-15.504, 14.478, 3.967)
	local meesh = Instance.new("SpecialMesh", haandl)
	meesh.MeshId = "rbxassetid://13030731"
	meesh.TextureId = "rbxassetid://13699943

this is the portion of the script that involves the hat I need rotated. Everything else works fine. Thank you

2 comments

0

Don't understand why this is getting flagged..

0

I'm new to this site, what does flagging it do?

1 answer

✓ Accepted answer

Hat works very similar to weld, so setting the rotation and position for the part won't do anything. You could actually avoid using hat and simply weld the part instead.


local haandl = Instance.new("Part", harr)
haandl.Name = "Hat"
haandl.Size = Vector3.new(1.42, 0.95, 1.8)
haandl.CanCollide = false

local meesh = Instance.new("SpecialMesh", haandl)
meesh.MeshId = "rbxassetid://13030731"
meesh.TextureId = "rbxassetid://13699943

--haandl.Position = Vector3.new()
--haandl.Rotation = Vector3.new()

-- Create weld and set the parts that you want to weld
local w = Instance.new( "Weld", plr.Head )
w.Part0 = plr.Head
w.Part1 = haandl

-- Set both position and rotation as CFrame
-- You both had handle position and attachment position set, so I didn't know which to use
-- Also, gotta convert degrees to radians in CFrame case
w.C0 = CFrame.new( 7.331, 5.096, -44.221 ) * CFrame.Angles( math.rad(-15.504), math.rad(14.478), math.rad(3.967) )

1 comment

0

Thanks, man I was looking for something like this, it'll make my scripting a lot easier.

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