So, before my gate moved perfectly fast and smooth, but not it moves inch by inch very slow and very roughly. This is the code: Anybody know how to fix it?
local trigger = script.Parent local gate = script.Parent.Parent.Gate moving = false open = false function onClick() if open == false and moving == false then moving = true trigger.BrickColor = BrickColor.new("Bright yellow") for i = 1, (gate.Size.Y * 10 + 1) do wait() gate.CFrame = gate.CFrame*CFrame.new(0, 0.1, 0) end moving = false open = true trigger.BrickColor = BrickColor.new("Bright red") elseif open == true and moving == false then moving = true trigger.BrickColor = BrickColor.new("Bright yellow") for i = 1, (gate.Size.Y * 10 + 1) do wait() gate.CFrame = gate.CFrame*CFrame.new(0, -0.1, 0) end moving = false open = false trigger.BrickColor = BrickColor.new("Bright green") end end script.Parent.ClickDetector.MouseClick:connect(onClick)
I'd recommend using the tweening service over loops like this. It'll be much cleaner and more reliable.