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

im trying to make it that when a player touches a brick they get teleported upwards?

Asked by 5 years ago

im trying to make it that when a player touches a brick they get teleported from where they are upwards but its not working

script.Parent.Touched:connect(function(t)
        if t.Parent.Humanoid ~= nil then

                t.Parent.HumanoidRootPart.CFrame = t.Parent.HumanoidRootPart.CFrame.new(0,20,0)

        end
end)

1 answer

Log in to vote
0
Answered by
AAzterr 27
5 years ago

CFrame.New does not work when trying to define the target's position. You have to make it look at the target's CFrame again, then add by 20 in the Y portion with Vector3. (assuming you want the player to go up instead of a certain position.) Fixed script is here:

script.Parent.Touched:connect(function(t)
        if t.Parent.Humanoid ~= nil then

                t.Parent.HumanoidRootPart.CFrame = t.Parent.HumanoidRootPart.CFrame + Vector3.new(0,20,0) --it looks at the target, and defines the position by adding 20 to the vector3 y position.

        end
end)

Hope you got it, and if it worked accept my answer.

Ad

Answer this question