Need Help making object rotate

I have been trying to make a little spinner thing that kills you when you touch it for a simple game I am making to try and test my scripting ability. I am trying to make it rotate, but I don’t know how to had specifically to the Y value. This is what I have so far, It would also help if you explain what certain things do, since I am learning scripting and trying to improve. Help would be appreciated.

local Blue = script.Parent
local BlueCFrame = CFrame.Angles(0,math.rad(90),0)
if true then
    	
    	Blue.CFrame = BlueCFrame	
    	end

What Im trying to make rotate

3 Likes

You need to set Blue’s CFrame value to BlueCFrame.

Blue.CFrame = BlueCFrame

2 Likes

To continuously rotate it change it to

Blue.CFrame *= BlueCFrame

1 Like

Inside the loop? I just tried changing Blue = BlueCFrame to Blue.CFrame = BlueCFrame

yep, inside the loop :ok_hand:

1 Like

I did that, and nothing happened.

This is what it should look like for what your doing:

game:GetService("RunService").Stepped:Connect(function()
    script.Parent.CFrame *= CFrame.Angles(0,math.rad(90),0)
end)

if you want it in a loop instead, do it like this:

while game:GetService("RunService").Stepped:Wait() do
    script.Parent.CFrame *= CFrame.Angles(0,math.rad(90),0)
end
3 Likes

You could just use a hinge or motor to make it spin

That does give it a spin effect, but it only stops at 4 points, I meant more of a smoother rotation such as when you use the rotate tool in studio.

For that, use tweenService:

local style = Enum.EasingStyle.Quint
game:GetService("TweenService"):Create(script.Parent, TweenInfo.new(1, style), {CFrame = script.Parent.CFrame * CFrame.Angles(0, math.rad(359.99), 0)}):Play()
2 Likes

Thats helps a lot, is there a way to make it slower?

My bad, lol i did 180 instead of 360. One thing to keep in mind however, is that if you loop it completely around 360 degrees, it will just stay in the same place and not move at all, replace it with this:

local timeToTakeForCompleteRotation = 1
local style = Enum.EasingStyle.Quint

game:GetService("TweenService"):Create(script.Parent, TweenInfo.new(timeToTakeForCompleteRotation / 2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 2), {CFrame = script.Parent.CFrame * CFrame.Angles(0, math.rad(180), 0)}):Play()
4 Likes