Hey guys! This is my first real post so please give any feedback if there is any!
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.
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)
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
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.
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
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.