I asked a question about the cover and things. Now I added a slot for it. But there was a problem for that. I want it where when I click it the cover and slot does the function like at the same time I should say. It is like a dvd player, where you click the button and the cover opens and slides the CD insert out. This is the script (Looks confusing):
--Combined script
local button = game.Workspace.Button
local slot = game.Workspace.Radio.Slot
local cover = game.Workspace.Radio.Cover
local home = cover.CFrame
debounce = false
function onClicked(button) --Supposed to work after you click the button and both the slot and cover come out at the same time
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
local positionZValues = {-5.535, -6.635, -7.365} -- Z Value for Position (I wanted it to be from -5.535 to -7.365)
if not debounce then
debounce = true
for a,v in pairs(positionZValues) do --This "for" loop runs through each value of the table
slot.Position = Vector3.new(0, 0, v) -- Only for Z value
wait(.001)
end
debounce = false
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
How I made it? Well, I got the cover script that someone made by shortening my script out, but then I combined it, which I kind of made it confusing to me. But I hope you guys understand. Sorry for the trouble.
