01 | local model = script.Parent |
02 | local available = true |
03 | function open() |
04 | if available = = true then |
05 | for i = 0 , 2 , 0.1 do |
06 | model:SetPrimaryPartCFrame(model:GetPrimaryPartCFrame() * CFrame.new(-. 25 , 0 , 0 )) |
07 | wait() |
08 | end |
09 | end |
10 | end |
11 | script.Parent.ClickDetector.MouseClick:connect(open) |
12 |
13 | if model.Main.Position > = Vector 3. new(- 244.769 , 139.06 , 51.98 ) then |
14 | print ( "part can't go any further!" ) |
15 | local available = false |
16 | 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:
01 | local model = script.Parent |
02 | local available = true |
03 | local isdoneMoving = false |
04 |
05 | local function open() -- use local functions |
06 | if available = = true and isdoneMoving = = false then |
07 | for i = 0 , 2 , 0.1 do model:SetPrimaryPartCFrame(model:GetPrimaryPartCFrame(CFrame.new(-. 25 , 0 , 0 ))) |
08 | wait() |
09 | end |
10 | isdoneMoving = true |
11 | end |
12 | end |
13 |
14 | open() -- i guess you want the function to execute automatically |
15 |
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