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

IntValue won't show up in player?

Asked by 7 years ago
function addValue()
    MC = Instance.new("IntValue")
    MC.Parent = game.Players.LocalPlayer
    MC.Value = 0
    MC.Name = "MoneyCount"
end


game.Players.PlayerAdded:Connect(addValue)

For some reason, the IntValue won't show up in my player and the variable MC is underlined blue. I want to know if I did something wrong. I'm really new to Lua so I don't really know much about it.

Also, I tried the code block thing for the first time so I'm not sure how it looks.

Thanks! Help would be appreciated.

1 answer

Log in to vote
0
Answered by
Lavical 15
7 years ago

game.Players.LocalPlayer is only a valid property client-side, while this should be done server-side. Instead, use a parameter to handle the player when they join.

local function onPlayerAdded(player)
    local moneyCount = Instance.new("IntValue")
    moneyCount.Name = "MoneyCount"
    moneyCount.Parent = player
end

game.Players.PlayerAdded:Connect(onPlayerAdded)

An IntValue's value by default is 0, so we don't bother setting it.

0
Oh, okay! Thanks a lot! This was very helpful! codytron3234 10 — 7y
Ad

Answer this question