Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Adding an IntValue into player?

Asked by 7 years ago

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

Log in to vote
0
Answered by
FiredDusk 1466 Moderation Voter
7 years ago
Edited 7 years ago
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 :)

Ad

Answer this question