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

IntValue won't show up in player?

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

✓ Accepted answer

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.

1 comment

0

Oh, okay! Thanks a lot! This was very helpful!

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