Currently, I am trying to teleport the player up by 2 studs. So, I made this script.
name = game.Players.LocalPlayer.Name
char = game.Workspace:FindFirstChild(name)
X = char.Torso.Position.X
Y = char.Torso.Position.Y
Z = char.Torso.Position.Z
game:GetService('Players').PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
character:WaitForChild("Humanoid").Died:connect(function()
game.Workspace.Player.Torso.CFrame = CFrame.new(Vector3.new(X,Y+2,Z))
end)
end)
end)
I figured that lines 1 and 2 would select the player, lines 4, 5, and 6 would state the X, Y, and Z positions of the torso. The function would simply move the torso up by 2 studs. I however get this error.
**20:34:09.172 - Workspace.Ragdolls.Script:1: attempt to index field 'LocalPlayer' (a nil value)
Help?

2 comments
LocalPlayer ONLY exists in LocalScripts. This causes you to need to remake your variables.
Thank you.