How do I make this go back after it goes to the last rotations which is 90? Like I want it where the x value for the rotation stops there and when I click it again, it goes backward. This is the script of BlueTaslem:
--BlueTaslem Answered Script (Thank you)
local cover = game.Workspace.Radio.Cover
local home = cover.CFrame
function onClicked()
for t = 0, 4.8, 0.03 do
wait(0.001)
local v = math.cos(t / 4.8 * math.pi) * 45 + 90 + 45
cover.CFrame = home
cover.Rotation = Vector3.new(v, 0, 180)
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
Added Debounce! It didn't work and did I do it right?
Link to what the problem is: https://www.youtube.com/watch?v=ZzG9NHdR81o&feature=youtu.be
--BlueTaslem Answered Script with LordDragonZord (Thank you)
local cover = game.Workspace.Radio.Cover
local rot = cover.Rotation
debounce = false
function onClicked()
if not debounce then
debounce = true
if rot == cover.Rotation then
for t = 0, 4.8, 0.03 do
wait(0.001)
local v = math.cos(t / 4.8 * math.pi) * 45 + 90 + 45
cover.CFrame = cover.CFrame*CFrame.Angles(v,0,0)
end
end
else
if not debounce then
debounce = true
for t = 0, 4.8, 0.03 do
wait(0.001)
local v = math.cos(-(t / 4.8) * math.pi) * 45 + 90 + 45
cover.CFrame = cover.CFrame*CFrame.Angles(v,0,0)
debounce = false
end
end
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

4 comments
You won't learn by stealing other people's code...
I didn't. I made like a huge script, and Validark made it shorter, and BlueTaslem made it shorter as well.
Well, to move it back i would assume you would just rotate it by -v and -180, but idk because that math stuff is confusing
Ikr. I had to use my basics way, which was Vector3.new() like bunch of times with the scale in it. Luckily, Validark made it better using the table method and BlueTaslem made it even smaller and well, better with the rotations I think. But both of them were good and I gotta to thank them for it.