1 | local function onTouchedBall(hit) |
2 | print (hit) |
3 | if hit.Parent:FindFirstChild( "Humanoid" ) then |
4 | hit.Parent.HumanoidRootPart.CFrame = CFrame.new(Vector 3. new(script.Parent.VehicleSeat.CFrame.Position)) |
5 | end |
6 | end |
7 |
8 | 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.
You made it too complicated as Block_manvn said just do:
1 | local function onTouchedBall(hit) |
2 | print (hit) |
3 | if hit.Parent:FindFirstChild( "Humanoid" ) then |
4 | hit.Parent.HumanoidRootPart.CFrame = script.Parent.VechicleSeat.CFrame |
5 | end |
6 | end |
7 |
8 | script.Parent.Touched:Connect(onTouchedBall) |
Read this to understand more about CFrames: https://developer.roblox.com/en-us/api-reference/datatype/CFrame