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")
		else
			print("player not found")
		end
	else
		print("player not high enough rank")
	end
end

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?

1 Like

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

balance.Value += snowballs
2 Likes

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

1 Like

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

1 Like

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

2 Likes

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