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

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

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

1 comment

0

Make use of the Position property inherited by BasePart. If it's a model, you can use MoveTo or SetPrimaryPartCFrame

1 answer

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.

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