How would this work...
I have this...
But I'm wondering if there would be a shorter way to do this
local plr = game.Players.LocalPlayer plr.stats.Kills.Changed:connect(function() if plr.stats.Kills.Value == 5 then plr.stats.Coins.Value = plr.stats.Coins.Value + 10 end end)
Hi Arxk,
Good start, but if you want to award the player with 10 coins for EVERY 5 kills they get, then you'd want to store the number of kills in a variable. Whenever the player gets five kills, the variable would be reset to 0 again and the process would repeat. It may sound hard to accomplish, but I think the code will speak for itself.
The error you made is where you check if the number of kills the player has is EQUAL to 5, in which case the player would only be awarded coins when they have 5 kills.
I'd assume you want plr.stats.Kills.Value
to display the total kills the player has, so that is why I still use that variable in the code.
local plr = game.Players.LocalPlayer local killCount = 0 local totalKills = plr.stats.Kills.Value local coins = plr.stats.Coins.Value totalKills.Changed:Connect(function() killCount = killCount + 1 if killCount == 5 then coins = coins + 10 killCount = 0 end end)
Hope this helped!