So I am working on a code system where you enter a promotional code and get coins. The major part of the script is done, but I cannot figure out how to reference the leaderstat. I have it set up so that it prints the message of redemption. I also need to figure out how to add to the value rather than change it. So can anyone help me? My script so far:
local codes = { ["aloha2020"] = function(player) print(player.Name .. " redeemed 100 dollars using code aloha2020!") end, } return(codes)
If you set up leaderstats the way any tutorial shows you, and the way you should to get stats on the playerlist, the way to do it is with the code below.
local codes = { ["aloha2020"] = function(player) print(player.Name .. " redeemed 100 dollars using code aloha2020!") player:WaitForChild("leaderstats"):WaitForChild("Dollars").Value = player:WaitForChild("leaderstats"):WaitForChild("Dollars").Value + 100; --Replace Dollars with your actual stat name. end, } return(codes)
(Also I don't see a check to see if they've already redeemed the code, do you have something in place for this?)
If this answered your question, please mark it as the solution so people know it's been solved and if they have the same problem they can get it fixed!
If you have more questions feel free to ask away.