I've tried to make a simple corpse script to test my capabilities, however it doesnt work. It tells me there was an invalid attempt to index local value leftarm which is a nil value. Im open to all tips and suggestions
game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) character:WaitForChild("Humanoid").Died:Connect(function() local leftarm = player:FindFirstChild("Left Arm") leftarm.RightSurface = Enum.SurfaceType.Weld local leftleg = player:FindFirstChild("Left Leg") leftleg.TopSurface = Enum.SurfaceType.Weld local rightarm = player:FindFirstChild("Right Arm") rightarm.LeftSurface = Enum.SurfaceType.Weld local rightleg = player:FindFirstChild("Right Leg") rightleg.TopSurface = Enum.SurfaceType.Weld local torso = player:FindFirstChild("Torso") torso:MakeJoints() end) end) end)
What's happening here is, you are :FindFirstChild
the bodyparts of the player, you are searching for them in the wrong place, you were searching for them inside the Player object, not its character.
A Player always has 2 forms or something like that: The Player object, which is found inside "Players" and contains anything that's local, such as ui inventories, and info about the player, such as its name and id....
And this thing doesn't contain the bodyparts, the character does.
The Character is the model found in workspace that represents the phyiscal form of the player, it has his bodyparts his humanoid...
As I said you were searching for the bodyparts inside the Player, that's wrong, you have to search for them inside the Character.
What was happening is :FindFirstChild wasn't finding the objects inside the player so it returned nil, so you're variable that represents the bodypart is nil. You were doing leftarm.Surface which is the equivilant, in this situation, to this nil.Surface and that would obviously error.
And that's it, replace Player with Character
game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) character:WaitForChild("Humanoid").Died:Connect(function() local leftarm = character:FindFirstChild("Left Arm") leftarm.RightSurface = Enum.SurfaceType.Weld local leftleg = character:FindFirstChild("Left Leg") leftleg.TopSurface = Enum.SurfaceType.Weld local rightarm = character:FindFirstChild("Right Arm") rightarm.LeftSurface = Enum.SurfaceType.Weld local rightleg = character:FindFirstChild("Right Leg") rightleg.TopSurface = Enum.SurfaceType.Weld local torso = character:FindFirstChild("Torso") torso:MakeJoints()