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

How do i make a ball/puck go back to it's start position when it hits a sensor?

Asked by 5 years ago

For example a goal is scored and the puck goes back to center ice.

0
Make use of the Position property inherited by BasePart. If it's a model, you can use MoveTo or SetPrimaryPartCFrame pidgey 548 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

What I like to do for this is have a clone of the part where I want it to move to named "Reference". What I would do in the sensor script would be this:

script.Parent.Touched:Connect(function(hit)
    if hit.Name == "Puck" then
        hit.CFrame = workspace.Reference.CFrame
        -- whatever else you need to happen
    end
end)

All this does is:

1.) Runs when it gets touched by an object.

2.) Checks if the object was the puck.

3.) If it was, change the coordinate frame of the object to the coordinate frame of the reference in the workspace.

Ad

Answer this question