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

i been getting this error when i do anything whith Character how do i fix?

Workspace.Script:3: attempt to index field 'Character' (a nil value)


game.Players.PlayerAdded:Connect(function(player)
	local Player = game.Players.LocalPlayer
	player.Character.Humanoid.MaxHealth = 1000000000000000000
		player.Character.Humanoid.Health = 1000000000000000000
end)

2 answers

✓ Accepted answer

The player's character does not load instantly, so you will have to wait until it is added. Your script looks like this when that is taken into account:

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function()

	player.Character.Humanoid.MaxHealth = 1000000000000000000 					 
        player.Character.Humanoid.Health = 1000000000000000000
	end)
end)

2 comments

0

You should have removed the LocalPlayer bit, since it is nil on the server and is redundant because you already have player defined.

0

I don't want to change anything to his script which may otherwise be useful to him

Why are you defining Player for a second time first off, remove that variable.

Second add a waitForChild or do local character = player.CharacterAdded:Wait() and then attempt to set their health and max health.

2 comments

0

Hey can you edit your answer on the baseplate turning black question?

0

i tyed that did not work :(

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