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

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

Asked by 5 years ago
1local function onTouchedBall(hit)
2    print(hit)
3    if hit.Parent:FindFirstChild("Humanoid") then
4        hit.Parent.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(script.Parent.VehicleSeat.CFrame.Position))
5    end
6end
7 
8script.Parent.Touched:Connect(onTouchedBall)

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

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) Block_manvn 395 — 5y

1 answer

Log in to vote
1
Answered by
Zero_Tsou 175
5 years ago
Edited 5 years ago

You made it too complicated as Block_manvn said just do:

1local 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

Ad

Answer this question