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

How can I make this script teleport the player to the specified location?

local function onTouchedBall(hit)
	print(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		hit.Parent.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(script.Parent.VehicleSeat.CFrame.Position))
	end
end

script.Parent.Touched:Connect(onTouchedBall)

I don't understand why it teleports me to the center of the map instead of the position I specified.

1 comment

0

I think you make it too complicated. HumanoidRootPart.CFrame = VehicleSeat.CFrame is enough (I reduce the code a little bit for readable, it is not full)

1 answer

✓ Accepted answer

You made it too complicated as Block_manvn said just do:

local function onTouchedBall(hit)
	    print(hit)
	    if hit.Parent:FindFirstChild("Humanoid") then
	        hit.Parent.HumanoidRootPart.CFrame = script.Parent.VechicleSeat.CFrame
	    end
	end
	 
	script.Parent.Touched:Connect(onTouchedBall)

Read this to understand more about CFrames: https://developer.roblox.com/en-us/api-reference/datatype/CFrame

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