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

New to coding and I don't quite understand this script + it isn't fully working, can anyone help?

Asked by 6 years ago
Edited 6 years ago

Basically I'm trying to make it teleport +50, 0, -30. I'm relatively new to coding and somebody tried to help me here but I don't quite get what's going on in the selection with asterisks surrounding it, nor how to fix it.

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

Mouse.KeyDown:connect(function(Key)
    Key = Key:lower()
    if Key == 'e' then
        **local humroot = character:FindFirstChild("HumanoidRootPart")
        local x, y, z, r00, r01, r02, r10, r11, r12, r20, r21, r22 = humroot.CFrame:Components()
        humroot.CFrame = CFrame.new(x + 50, y, z - 30, r00, r01, r02, r10, r11, r12, r20, r21, r22)**
    end
end)

1 answer

Log in to vote
0
Answered by
PlaasBoer 275 Moderation Voter
6 years ago

Here is simpler version

Code is tested in studio and works.

Note! --This should be in local script. --This won't work on FE game since you teleport in local script so other people won't see it read more on remote events below to make it FE. --And also you can add in game.StarterPlayer.StarterPlayerScripts to work.

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

Mouse.KeyDown:connect(function(Key)
    Key = Key:lower()
    if Key == 'e' then
        local humroot = game.Workspace[Player.Name]:FindFirstChild("HumanoidRootPart")
        humroot.CFrame = CFrame.new(humroot.Position.X + 50, humroot.Position.Y, humroot.Position.Z - 30)
    end
end)

https://wiki.roblox.com/index.php?title=Remote_Functions_%26_Events

Ad

Answer this question