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

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

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

✓ Accepted answer

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.

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