Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How can I make this model not go any further?

Asked by
Stravan 18
6 years ago
01local model = script.Parent
02local available = true
03function 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
10end
11script.Parent.ClickDetector.MouseClick:connect(open)
12 
13if model.Main.Position >= Vector3.new(-244.769, 139.06, 51.98) then
14    print("part can't go any further!")
15    local available = false
16end

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.

0
You will need to compare each component of the Vector3 to it's corresponding one. You can also try calculating magnitude between the two parts if you don't have to use that specific point on line 13. xPolarium 1388 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

you could just put a Boolean variable to check if model is done moving like this:

01local model = script.Parent
02local available = true
03local isdoneMoving = false
04 
05local 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
12end
13 
14open() -- i guess you want the function to execute automatically
15 
View all 21 lines...

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

Ad

Answer this question