I put all the names that gonna get the gold in a table, but inst a String, it is an ObjectValue.
local gold = 25 -- 'players' is the table within 2 Object Values. for _,v in pairs(players) do v.Value.Stats.Gold.Value = v.Value.Stats.Gold.Value + gold end
when I send gold to the players, for example, player1, and player2 the condition gives 2x gold for player 1 and 1x gold to player 2. Why?
The same thing happens here:
local gold = 25 for b = 1,#players do players[b].Value.Stats.Gold.Value = players[b].Value.Stats.Gold.Value + gold end
Create a function that will do this for you automatically. Call the function whenever you want to give all players x gold. Check out the code below.
local Players = game:GetService("Players"); function giveGold (goldAmount) for _, player in pairs(Players) do local gold = player.Value.Status.Gold; gold.Value = gold.Value + goldAmount; end end
Then simply call the function with
giveGold(25) and it should work as a charm.