This is in the starterpack
local player = game.Players.LocalPlayer function onKeyPress(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.X then player.Character.Torso.CFrame = CFrame.new(player.Character.Torso.Position.x,player.Character.Torso.Position.y+30,player.Character.Torso.Position.z) end end game:GetService("UserInputService").InputBegan:connect(onKeyPress)
Another simple fix that goes unnoticed by many! Your problem is that this script is firing before the LocalPlayer loads. Therefor the code can't find game.Players.LocalPlayer because it's not there yet! So we need to add a simple loop to yield the script until the LocalPlayer loads.
repeat wait() until game.Players.LocalPlayer --this will allow the rest of the script to activate once the character is fully loaded! local player = game.Players.LocalPlayer function onKeyPress(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.X then player.Character.Torso.CFrame = CFrame.new(player.Character.Torso.Position.x,player.Character.Torso.Position.y+30,player.Character.Torso.Position.z) end end game:GetService("UserInputService").InputBegan:connect(onKeyPress)