So I'm trying to make a model with a primary part slide up and down on every click (Up on click one, Down on click two), but when I click it. Bam, nothing! Nor no errors.
function click() if(script.Parent.Status.Value)=="Closed" then script.Parent.Status.Value="Opening" movements=0.2 speed=0.2 for i=1,movements do wait(0.01) script.Parent.PLT:SetPrimaryPartCFrame(script.Parent.PLT.PrimaryPart.CFrame + Vector3.new(0,speed,0)) end script.Parent.Status.Value="Open" elseif(script.Parent.Status.Value)=="Open" then script.Parent.Status.Value="Closing" movements=0.2 speed=0.2 for i=1,movements do wait(0.01) script.Parent.PLT:SetPrimaryPartCFrame(script.Parent.PLT.PrimaryPart.CFrame + Vector3.new(0,-speed,0)) end script.Parent.Status.Value="Closed" end end script.Parent.PLT.ClickDetector.MouseClick:connect(click)
local status = script.Parent.Status local plt = script.Parent.PLT local speed = 0.2 local movements = 2 function click() if (status.Value == "Closed") then status.Value = "Opening" for i=1, movements do wait(0.01) plt:SetPrimaryPartCFrame(plt.PrimaryPart.CFrame + Vector3.new(0,speed,0)) end status.Value="Open" else status.Value="Closing" for i=1, movements do wait(0.01) plt:SetPrimaryPartCFrame(plt.PrimaryPart.CFrame + Vector3.new(0,-speed,0)) end script.Parent.Status.Value="Closed" end end plt.ClickDetector.MouseClick:connect(click)
for i=1, 0.2 do -- (0.2 from your movements variable)
Has no effect as the default step is 1.
Instead you should use:
for i=1, 2 do
To loop twice.
I've also tidied up the script a bit.