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

Help with click detector?

Asked by
FiredDusk 1466 Moderation Voter
9 years ago

When I click a model moves to 1,1,1 but when I click again, I want the model to move where it was before you clicked the first time.

1Part = script.Parent
2Model = game.Workspace:WaitForChild("Model")
3 
4Part.ClickDetector.MouseClick:connect(function()
5    Model:MoveTo(Vector3.new(1,1,1))
6end)

1 answer

Log in to vote
1
Answered by 9 years ago

You need to save the coordinates of where it was in the first place

01local x, y, z = 0, 0, 0
02 
03part.ClickDetector.MouseClick:connect(function()
04    if Model.Position.X ~= 1 and Model.Position.Y ~= 1 and Model.Position.Z ~= 1 then
05        x = Model.Position.X
06        y = Model.Position.Y
07        z = Model.Position.Z
08 
09        Model:MoveTo(Vector3.new(1,1,1))
10    else
11        Model:MoveTo(Vector3.new(x,y,z))
12    end
13end)
0
Model does not use "Position" FiredDusk 1466 — 9y
Ad

Answer this question