So, i've created a pipe wheel, and when the player presses "E" then it rotates but now, it just spins somewhere instantly, not smoothly. Here's the code:
local prox = script.Parent.wheel.Union.ProximityPrompt prox.Triggered:Connect(function() for i = 1, 100, 1 do script.Parent.wheel.Union.CFrame = script.Parent.wheel.Union.CFrame * CFrame.fromEulerAnglesXYZ(0.5,0,0) * CFrame.new(0, 0, 0) end end)
You need to add a wait() after one run-through of the loop (line 6). Currently it does not wait after doing a cycle so it will instantly run the loop and finish within a fraction of a second. If it is still too fast, increase the wait time, but the more you increase it the choppier it will become.
A more elegant solution would be to use tweening, which is a built-in system for smooth changes.
Not sure I got the pathing correct since I was using a part with a script under it for my setup but otherwise it works
local prox = script.Parent.wheel.Union.ProximityPrompt local tweenService = game:GetService("TweenService") local rotationTime = 5 local tweeningInformation = TweenInfo.new(rotationTime, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false) prox.Triggered:Connect(function() local tweenProperties = { CFrame = script.Parent.wheel.Union.CFrame * CFrame.Angles(math.rad(180),0,0) * CFrame.new(0, 0, 0) } local Tween = tweenService:Create(script.Parent.wheel,tweeningInformation,tweenProperties) Tween:Play() end)