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.
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.