Ok so the payday thing is not working for some reason but it shows no script errors it counts down to 1 then does not pay.
function onPlayerEntered(newPlayer) wait(0.5) local stats = Instance.new("IntValue") stats.Name = "leaderstats" local cash = Instance.new("IntValue") cash.Name = "Cash" cash.Value = 0 cash.Parent = stats stats.Parent = newPlayer end game.Players.PlayerAdded:connect(onPlayerEntered) time = 150 while true do wait(1) time = time - 1 if (time == 0) then time = 180 players = game.Players:GetChildren() for i=1, #players do if (players[i]:findFirstChild("leaderstats")) then if game.Players.LocalPlayer.TeamColor == game.Teams.Citizens.TeamColor then -- Citizens players[i].leaderstats.Cash.Value = players[i].leaderstats.Cash.Value + 50 elseif game.Players.LocalPlayer.TeamColor == game.Teams["Department of Corrections"].TeamColor then -- Dep of Corr players[i].leaderstats.Cash.Value = players[i].leaderstats.Cash.Value + 150 elseif game.Players.LocalPlayer.TeamColor == game.Teams["Norfolk City Fire & Rescue"].TeamColor then -- Fire and Rescue players[i].leaderstats.Cash.Value = players[i].leaderstats.Cash.Value + 100 elseif game.Players.LocalPlayer.TeamColor == game.Teams.Visitor.TeamColor then -- Visitor players[i].leaderstats.Cash.Value = players[i].leaderstats.Cash.Value + 75 elseif game.Players.LocalPlayer.TeamColor == game.Teams["NCPD SWAT"].TeamColor then -- NCPD SWAT players[i].leaderstats.Cash.Value = players[i].leaderstats.Cash.Value + 250 elseif game.Players.LocalPlayer.TeamColor == game.Teams["Norfolk City Police"].TeamColor then -- Norfolk City Police players[i].leaderstats.Cash.Value = players[i].leaderstats.Cash.Value + 125 end end end end playersa = game.Players:GetChildren() for i=1, #playersa do playersa[i].PlayerGui.Norfolk_v1.Cash.TextLabel.Text = "Payday In: " .. tostring(time) end end
I hope someone can help me out with this!
If this is in a ServerScript, then you do not have access to the property LocalPlayer. Additionally, if this is in a LocalScript given to every player, it will create a new leaderboard for everyone when someone joins.
Therefore there are a couple of improvements we can make. I would suggest using a server script as it is something that affects every player in the game (see Client-Server Model).
Now, every 150 seconds you'll need to give every player their pay dependant upon their team color. An easy way to do this is to use a dictionary to associate different pays with different team colors.
local time = 150 local payout = { ["Bright red"] = 50, ["Bright green"] = 100, ["Bright blue"] = 150, -- etc } game.Players.PlayerAdded:connect(function(player) local stats = Instance.new("IntValue", player) stats.Name = "leaderstats" local cash = Instance.new("IntValue", stats) cash.Name = "Cash" cash.Value = 0 end) while wait(1) do time = time - 1 if time = 0 then for _, player in next, game.Players:GetPlayers() do player.leaderstats.Cash.Value = payout[player.TeamColor] end time = 180 end for _, player in next, game.Players:GetPlayers() do player.PlayerGui.Norfolk_v1.Cash.TextLabel.Text = "Payday In: " .. tostring(time) end end)