Help with teleport

So im making a soccer game and i need when the ball hits a canCollide off part it changes a GUI teleports the players to the spawn points and to teleport the ball to the middle of the field. All I have now is a teleport script for a humanoid but how would i make it teleport only parts?
Here is the script:

local Teleport = "Lentilkac58-Easy-Teleport-2" --Put the name of the Part between the ""s.
function Touch(hit) --Indicates that the Part has been Touched.
	if script.Parent.Locked == false and script.Parent.Parent:findFirstChild(Teleport).Locked == false then script.Parent.Locked = true script.Parent.Parent:findFirstChild(Teleport).Locked = true --Checks Debounce.
	local Pos = script.Parent.Parent:findFirstChild(Teleport) --Gets the Part to teleport to.
		hit.Parent:moveTo(Pos.Position) wait(1) script.Parent.Locked = false script.Parent.Parent:findFirstChild(Teleport).Locked = false end end --Takes you there and Ends the Function.
script.Parent.Touched:connect(Touch) --Listens out for Touchers.

Would you not just kill the player to make them spawn back to the spawn area and then change the ball CFrame to the middle of the field.

If you really don’t want the user to die just change the CFrame to the spawn area instead of killing them.

sorry but im a noob to scripting how would you do that

you can do

Soccerball.CFrame = CFrame.new(x,y,z)

for the player you can do

Character.HumanoidRootPart.CFrame = CFrame.new(x,y,z)

or you can use :PivotTo

Not related to your problem, but you’re using deprecated camelCase APIs in the script.

  • Don’t use :findFirstChild, :connect or :moveTo
  • Also, don’t use wait.