Hello,
I'm trying to make a spinner which the player stands on to move around the map. I have tried to use BodyGyro and CFrame to do this.
I find that CFrame studders from degree to degree, which doesn't look very aesthetic. This was my attempt at using CFrame to move the part:
local brick = script.Parent local a = 0 while true do wait() local a = a + 0.04 brick.CFrame = brick.CFrame * CFrame.Angles(0, a ,0) end
Again, this did work, but it wasn't very smooth.
I couldn't get the BodyGyro attempt to work either. Firstly, because I had to unanchor the block, causing the block to fall out of the map. Secondly, because it just didn't rotate :(
This was my attempt on using BodyGyro to rotate the part:
local brick = script.Parent local body = script.Parent:FindFirstChild("BodyGyro") local a = body.CFrame.Y while true do wait() local a = a + 1 body.CFrame = CFrame.Angles(0,a,0) end
And again, this script didn't work at all :(
I would be grateful if you could help me create this smooth rotating block. Thanks.
you can use TweenService
to tween the part smoothly.
local ts = game:GetService("TweenService") local part = script.Parent -- lets say this was the part local info = TweenInfo.new(5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out,-1) local properties = {CFrame = script.Parent.CFrame * CFrame.Angles(0,math.rad(180),0)} local tween = ts:Create(script.Parent,info,properties) tween:Play() -- plays the tween --[[ tween:Cancel() -- stops the tween tween.Completed -- when the tween finishes --]]
TweenInfo.new()
actually takes 6 parameters, though you dont need to use all of them. the first parameter is how long should the tween go to the objective, for this it would take 5 seconds to rotate 180 degrees. Enum.EasingStyle.Linear
is just a easing style, you can choose other easing styles too. the rest you can find out here TweenInfo.new().