local model = script.Parent local available = true function open() if available == true then for i = 0,2,0.1 do model:SetPrimaryPartCFrame(model:GetPrimaryPartCFrame() * CFrame.new(-.25,0,0)) wait() end end end script.Parent.ClickDetector.MouseClick:connect(open) if model.Main.Position >= Vector3.new(-244.769, 139.06, 51.98) then print("part can't go any further!") local available = false end
I'm pretty sure the whole Vector3.new thing is wrong, but I'm not sure how to make the model not go any further once the PrimaryPart is or past a certain coordinate.
you could just put a Boolean
variable to check if model is done moving like this:
local model = script.Parent local available = true local isdoneMoving = false local function open() -- use local functions if available == true and isdoneMoving == false then for i = 0,2,0.1 do model:SetPrimaryPartCFrame(model:GetPrimaryPartCFrame(CFrame.new(-.25,0,0))) wait() end isdoneMoving = true end end open() -- i guess you want the function to execute automatically script.Parent.ClickDetector.MouseClick:Connect(function() -- connect is decaperated and you forgot to put "function" because the event is connecting to the function if isdoneMoving == true then print("part can't go any further!") local available = false end end)
you also didnt call the function open so it wont execute, and theres probably scripting mistakes i didnt notice, so correct me. theres probably better ways then doing this, but im too clumsy right now lol