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

How do I make a part that has a changed position go back to it's original position?

Asked by 5 years ago

Code I have so far:

script.Parent.ClickDetector.MouseClick:Connect(function()
    script.Parent.CFrame = script.Parent.Parent["FrontHood_I"].CFrame
    script.Parent.Orientation = ("0, 0, -30")
end)

Now that it's position is exactly FrontHood_I's, how do I make it go back to it's original position?

1 answer

Log in to vote
1
Answered by 5 years ago

You should store the position in a variable before you change it and then have it go to the position stored in the variable when you need to.

Sample code:

local myPart = Instance.new("Part") -- Create a part
local myPartPos = myPart.Position -- Reference this to get the original position
-- Code below
0
Oh... shoot.. But thanks! sean_thecoolman 189 — 5y
0
If I helped, mark this answer as accepted please! BennyBoiOriginal 293 — 5y
Ad

Answer this question