Helping with head and attachment rotation tweening

Hey guys! This is my first real post so please give any feedback if there is any!

  1. What do you want to achieve? I am trying to make a script that tweens the rotation of the head and it’s attachments on a while true do loop.

  2. What is the issue? I have two issues.

    • The script does not work I am not sure why and I have tried changing multiple things such as variables but to no avail.
    • The attachments I believe won’t rotate with the head The head, when it may rotate, I am pretty sure that the attachments will not follow suit. What leads me to believe this is that when I directly change the Orientation property in the workspace, the attachments, although they have a weld, do not rotate with it. (not using the rotate tool, changing it in the Properties tab)
  3. What solutions have you tried so far? I have looked for solutions on the DevHub, just to find a barely documented article on the Orientation property. I also tried changing how I put my variables, also to no avail.

Here is my code, which I put within the Humanoid because it is for display on a main menu.

local head = script.Parent.Head
local orient = head.Orientation
local ts = game:GetService("TweenService")
local ti = TweenInfo.new(0.5, Enum.EasingStyle.Quint, Enum.EasingDirection.Out)
local tIn = {orient = Vector3.new(0.48,27.14,-2.41)} 
local tOut = {orient = Vector3.new(0.48,-23.73,-2.41)} 
local createIn = ts:Create(head, ti, tIn) 
local createOut = ts:Create(head, ti, tOut) 

while true do
	createIn:Play()
	wait(math.random(0.8,1.2))
	createOut:Play()
	wait(math.random(0.8,1.2))
end

Thanks very much in advance,
Curse

yes i did use @TheCarbyneUniverse 's tween script, but just because i am absolutely terrible at setting up tweens

2 Likes

Instead of orientation, try using CFrame.Angels.

I’m pretty sure that the Orientation property needs Vector3

DONT USE orient. Use the full name of Orientation.

Why should he not use orient? It already has been defined as a variable.

I tried that but it had and error and said this:
Expected name, got a complex expression

This is how the service works. You must specify it in full name because the service will look at the part’s property and try to find Orientation, he used orient, which means the script will find a property named orient in that part which doesn’t exist. You can see other scripters specifying the property in full name in tutorials.

REmove the Orientation and try again.

1 Like

Didn’t work.

Try, try, try again!

Show me the error of the script.

Yep, the dictionary (the table) needs to have indexes of property names of the instance you are tweening. Another thing i noticed is that you are doing math.random(0.8, 1.2), which won’t work, math.random needs to use integers for it to work, so use Random.new() instead. This will work:

local head = script.Parent.Head
local ts = game:GetService("TweenService")

local ti = TweenInfo.new(0.5, Enum.EasingStyle.Quint, Enum.EasingDirection.Out)

local tIn = {Orientation = Vector3.new(0.48,27.14,-2.41)} 
local createIn = ts:Create(head, ti, tIn) 

local tOut = {Orientation = Vector3.new(0.48,-23.73,-2.41)} 
local createOut = ts:Create(head, ti, tOut) 

local thisRand = Random.new() -- because we dont have to create a new random object every time we find a random number
while true do
	createIn:Play()
	wait(thisRand:NextNumber(0.8, 1.2))
	createOut:Play()
	wait(thisRand:NextNumber(0.8, 1.2))
end
1 Like

expectedaname

Thank you that is absolutely perfect!

My only remaining issue is that the attachments do not tween with it.

Remove the variables orient. And then try again

elaborate on the attachments more. Maybe you could use a weld instead

Thanks for the reply, but I got it working thanks to @Moonvane
I still need to figure out how to make the attachments tween with it, but I have to go now so any suggestions I will read tomorrow as it is very late where I am.

Looks like I didn’t managed to help you solved, but I hope you understand better now.

1 Like

Apologies, but I don’t understand welding and rigging whatsoever.

do you just want a part to move orbitly around the head when you play the tween?

I want the ‘hats’ to move with the head.

Not sure if that is what orbiting is, but I think not.