I coded a currency system for my sniper game and can’t seem to fix it
separate scripts btw
is leaderstats already created? are you getting errors?
LocalPlayer
only works in local scripts
Second Script seems fine however you are trying to get the LocalPlayer in the first script. Im assuming you are making the Curreny System on a Server Script in which case you can’t use LocalPlayer. I also dont see you making the leaderstats folder at all which means you will just result in an error. Since you are trying to add 5 Currency when the player joins, I would add the 5 Currency in the PlayerAdded Event.
Here is how I would approach this:
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
local currency = Instance.new("IntValue", leaderstats)
currency.Name = "Currency"
currency.Value += 5
end)
Let me know if this works, I just quickly typed this out so there might be an error.
Edit: nevermind, in the second script in order to get the killer you need to get the value of the ObjectValue so you would have to change the currency value to:
local currency = killer.Value.leaderstats.Currency
This would go in the second script.