Adding money on Mob Kill

I want to give the player 10 Dosh when a mob is killed in my tower defense game. This is how I am trying to do it:

newMob.Humanoid.Died:Connect(function()
			newMob:Destroy()
			
			local player = map.Player1.Value.Value
			local money = game.Players:FindFirstChild(player).Dosh.Value
			local round = workspace.GameValues.Round.Value
			print(money)
			money += 10*round
			print(money)
end)

The first print is the players money before being added, the send print is that value plus 10.

However, the players dosh does not actually go up by 10, and whenever another mob is killed right after the first, it will print the same values as the first mob.

image

im not really sure but u coul specify the plr and money variables before the function and it could work (i think)

I tried this, and it didn’t change

This is because the variable represents property value. This creates a variable representing 10 now, changing it changes a number, not a property. Create a variable for the instance and use Instance.Value instead.

1 Like

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