Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Help with click detector?

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.

Part = script.Parent
Model = game.Workspace:WaitForChild("Model")

Part.ClickDetector.MouseClick:connect(function()
	Model:MoveTo(Vector3.new(1,1,1))
end)

1 answer

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

local x, y, z = 0, 0, 0

part.ClickDetector.MouseClick:connect(function()
	if Model.Position.X ~= 1 and Model.Position.Y ~= 1 and Model.Position.Z ~= 1 then
		x = Model.Position.X
		y = Model.Position.Y
		z = Model.Position.Z
		
		Model:MoveTo(Vector3.new(1,1,1))
	else
		Model:MoveTo(Vector3.new(x,y,z))
	end
end)

1 comment

0

Model does not use "Position"

This discussion is preserved as it was. New answers, comments, and votes are closed.