Hello fellow programmers,
I have a question I could not find the answer for, so I am hoping to find an answer here.
My question is: How would I have a piece of machinery (in this case, a pulley), vibrate, to create an aesthetic as if it were moving/working? I have written some code below, but the object does not seem to move. However, if I remove the second line of code (which is labeled --(KL)), the object would move, but only up, as expected. My intention was for the object to move up, and after the wait duration, it would move back down and repeat. How this script works is that when a player would click a button, the script would be enabled for two seconds, and then disabled. During this two second duration, the machine will seem to be 'working', releasing smoke and moving the pulley slightly. It would be nice to still use a similar CFrame to fix this, but I am willing to learn a new solution. There is no error output, and technically this should work, but I believe what happens is that the part just doesn't move fast enough for the position difference to be shown on display, but I'm not sure. Either ways, here is the code:
local part = script.Parent
while true do
part.CFrame = CFrame.new(part.CFrame.X, part.CFrame.Y + .5, part.CFrame.Z)
wait(.1)
part.CFrame = CFrame.new(part.CFrame.X, part.CFrame.Y - .5, part.CFrame.Z) --(KL)
end
Thank you for reviewing my question,
--RuskiKrolik

2 comments
Just want to say that you don't need to be so formal, but you should accept Diezel's answer, it is correct.
My main goal with being formal is to be easy to understand, which in result would have my question answered sooner. I also wanted to inform the respondent what is happening in the situation, so there would not have to be a back and forth commenting about the respondent needing more information.