Why isn't my command working?

I’m trying to make a command to give a certain player a certain amount of in-game currency. However, this command isn’t working. Here’s the command:

commands.givesnowballs = function(sender, arguments)
	if sender:GetRankInGroup(11635716) >= 254 then
		print("player has rank")
		local playerName = arguments[1]
		local player = findPlayer(playerName)
		if player then
			local guiStats = player:WaitForChild("guiStats")
			local balance = guiStats:WaitForChild("Snowballs")
			local snowballs = tonumber(arguments[2])
			balance = balance.Value + snowballs
			print("snowballs given")
			print("player not found")
		print("player not high enough rank")

The confusing thing is that it prints “snowballs given”, but it doesn’t give the snowballs. There are no errors in the output. How do I fix this?

On this line youre adding the amount to the balance variable, not the Snowballs value, Change that line to this:

balance.Value += snowballs
1 Like

The balance value is the amount of snowballs the receiver has. Sorry for the confusion.

Yes but youre only changing the balance variable, not the actual value of Snowballs the player has.

Oh wait nevermind, that did work. Thank you!!!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.