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 4 years ago
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.

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 — 4y

1 answer

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

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

Ad

Answer this question