Hello! I’m working on a game and I’m trying to implement Premium Benefits. Basically, I’m making a script that will award 10 extra “Cash” every minute of playing, below is my current script. Also, I did look at the DevForum tutorial.
local Players = game:GetService("Players")
local player = Players.LocalPlayer
amount = 10
timedelay = 60
currencyname = "Cash"
if player.MembershipType == Enum.MembershipType.Premium then
while true do
wait(timedelay)
for i,v in pairs(game.Players:player()) do
if v:FindFirstChild("leaderstats") and v then
v.leaderstats[currencyname].Value = v.leaderstats[currencyname].Value + amount
print("Added premium playtime cash to " .. v.Name .. ".")
end
end
end
end
Becuase this is a script, “LocalPlayer” doesnt work as it only works in local scripts. Instead add a playeradded function like this:
game.Players.PlayerAdded:Connect(function(player)
amount = 10
timedelay = 60
currencyname = "Cash"
if player.MembershipType == Enum.MembershipType.Premium then
amount += 10
end
while wait(timedelay) do
if player:FindFirstChild("leaderstats") then
if player.leaderstats:FindFirstChild(currencyname) then
player.leaderstats[currencyname].Value += amount
end
end
end
end)
oh lol, I wasn’t paying as much attention as I could have but I was pointing out the main error I saw. I’ll just remake some of the script to make it better.