I have a script, but it seems really blocky, and slow.
I was wondering if it would be possible to make it more efficient.
local PLT = script.Parent.Parent.Parent local movements = 60 local speed = 0.1 local open = false script.Parent.MouseClick:connect(function() if open == false then for i=1,movements do wait(0.001) PLT:SetPrimaryPartCFrame(PLT.PrimaryPart.CFrame + Vector3.new(0,speed,0)); end open = true elseif open == true then for i=1,movements do wait(0.001) PLT:SetPrimaryPartCFrame(PLT.PrimaryPart.CFrame + Vector3.new(0,-speed,0)); end open = false end end)
There are only some small improvements but I would not use "wait()" to determine time. Use tick() as it will be more accrete.
local PLT = script.Parent.Parent.Parent local movements = 60 local speed = 0.1 local open = false script.Parent.MouseClick:connect(function() if open then -- can only be true or do the other so lets change this around for i=1,movements do wait(0.001) PLT:SetPrimaryPartCFrame(PLT.PrimaryPart.CFrame + Vector3.new(0,-speed,0)); end open = false else for i=1,movements do wait(0.001) consistant PLT:SetPrimaryPartCFrame(PLT.PrimaryPart.CFrame + Vector3.new(0,speed,0)); end open = true end end)
Hope this helps.