I made this script, which is in basics, but when I clicked it, the position of the part went up and not in the position where it is. I just want the position the same until one specific line for where the part will move a little back, which is the Z axis, to make it a little better for going down. This is the script:
local cover = game.Workspace.Cover local slot = game.Workspace.Slot debounce = false function onClicked() if not debounce then debounce = true cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(-180, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(179, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(178, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(177, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(176, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(175.9, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) -- Only Z Axis move back instead, but should still work in any direction as long the z axis move back a little. cover.Rotation = Vector3.new(175.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(174.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(173.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(172.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(171.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(170.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(169.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(168.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(167.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(166.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(165.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(164.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(163.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(162.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(161.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(160.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(155.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(150.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(145.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(140.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(135.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(130.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(125.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(120.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(115.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(110.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(105.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(104.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(103.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(102.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(101.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(100.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(99.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(98.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(97.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(96.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(95.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(94.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(93.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(92.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(91.413, 0, -180) wait(.1) cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(90.293, 0, -180) debounce = false end end script.Parent.ClickDetector.MouseClick:connect(onClicked)
Please help. I can't even fix it much since I am not pro scripter. Thank you.
local cover = game.Workspace.Cover local slot = game.Workspace.Slot debounce = false --Creates a table of values local rotationXValues = {-180, 179, 178, 177, 176, 175.9, 175.413, 174.413, 173.413, 172.413, 171.413, 170.413, 169.413, 168.413, 167.413, 166.413, 165.413, 164.413, 163.413, 162.413, 161.413, 160.413, 155.413, 150.413, 145.413, 140.413, 135.413, 130.413, 125.413, 120.413, 115.413, 110.413, 105.413, 104.413, 103.413, 102.413, 101.413, 100.413, 99.413, 98.413, 97.413, 96.413, 95.413, 94.413, 93.413, 92.413, 91.413, 90.293} function onClicked() if not debounce then debounce = true for a,v in pairs(rotationXValues) do --This "for" loop runs through each value of the table cover.CFrame = CFrame.new(cover.CFrame.X, 1.981, -9.37) cover.Rotation = Vector3.new(v, 0, -180) wait(.1) end debounce = false end end script.Parent.ClickDetector.MouseClick:connect(onClicked)