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

Adding an IntValue into player?

Hello scripters! I have been trying to create an IntValue as soon as game.Players.PlayerAdded I wanted to make the value name "healthval" and Parent to be my local player. This is the code i tried using, but it did not work.

game.Players.PlayerAdded:connect(function(plr)
	Instance.new("IntValue").Parent = plr
	local healthval = plr:FindFirstChild("Value")
	healthval.Name = 'healthval'

	
	
end)

1 answer

✓ Accepted answer
game.Players.PlayerAdded:Connect(function(Player) --"Player" in the parenthesis is referring to the player that joined (your player).
		local val = Instance.new('IntValue') --Here, we need to make the value a variable so we can change its properties.
    val.Name = 'healthval'
    val.Value = 0 
    val.Parent = Player --It is always best to parent a object last.
end)

If this helped, please be sure to accept and upvote my answer :)

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