Hello! I am working on how to make a natural swaying animation for my part with a decal of leaves. I’m attempting to create a moving part with leaf decals so it’ll look like a swaying tree branch for my model. I’ve got a script on test here:
pos = script.Parent.Position
pos = Vector3.new(pos.x, pos.y-0.2, pos.z)
x = 0
z = 0
T = -99999
tall = script.Parent.Size.Y / 2
math.randomseed(tick())
rand = (math.random(0,20))/10
while true do
x = pos.x + (math.sin(T + (pos.x/5)) * math.sin(T/9))/3
z = pos.z + (math.sin(T + (pos.z/6)) * math.sin(T/12))/4
script.Parent.CFrame =
CFrame.new(x, pos.y, z) * CFrame.Angles((z-pos.z)/tall, 0,(x-pos.x)/-tall)
wait()
T = T + 0.12
end
This is from another model I found and I duplicated it on my own tree model, specifically I duplicated the script into the part with the decals of leaves. It turned out great, it works and sways naturally just like I wanted, however, it doesn’t seem to be working for the other parts of my model, it only works on a particular part, even though the other parts were just duplicated parts of the other part where the script worked.
The script does work, but the other parts are not showing up. Here is a closer look:
But when the studio is on building mode, the parts show up to their original position:
I can’t post my video screen record, the file isn’t uploading here.
UPDATE: I think the problem is the position of the part in the script, since they are all duplicated, the parts must have the same positions as the script told it. However, I do not know clearly which part of the script must need fixing.