Hope this isn't a repeat question. I have made this obstacle where you jump onto a swing that moves back and forth, but the swing moves incredibly fast. I'd like it to move about as fast as a hinged swing would move, but I haven't found a way to change the speed.
Here is my script:
while true do --Infinite loop --Tilt Parent for i = 1, 19 do --Iterate from numbers 1 to 19 script.Parent.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(0.055,0,0) wait() end wait() --Wait --Untilt Parent for i = 1, 19 do --Iterate from numbers 1 to 19 script.Parent.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(-0.055,0,0) wait() end end
This is how I would handle this:
local partCFrame = script.Parent.CFrame local swingSpeed = 1 local swingAmplitude = 0.055 -- How far it should swing local t = 0 while true do local delta = wait() -- Wait returns the amount of time it waited t = t + delta -- Just keep track of time -- Sine function makes perfect graph for this sort of swinging animation script.Parent.CFrame = partCFrame * CFrame.fromEulerAnglesXYZ( math.sin( t * swingSpeed ) * swingAmplitude,0,0) end