Alright so I am making a paycheck script and I am making it so it pops up with a notification that you received the money. The paycheck depends on the player's team. But instead of showing the money a player received, it shows 0. How do I fix this? My code (Local):
local MoneyValue = workspace.Leaderboard.PayCheck.Value
script.Parent.Text = "You've Received $"..MoneyValue --Updates the money with value doesn't work
while wait(60) do
script.Sound.Playing = true
script.Sound.Looped = false
script.Parent.Parent.Visible = true
wait(5)
script.Sound.Playing = false
script.Parent.Parent.Visible = false
end
It still gives the money to the player but I want this to show the money the player has received Edit 1: After changing teams it will show the money a player has gotten but from the last team Leaderboard Script (Just in case):
local datastore = game:GetService("DataStoreService")
local ds1 = datastore:GetDataStore("CashSaveSystem")
game.Players.PlayerAdded:Connect(function(plr) -- Capital 'C'
local folder = Instance.new("Folder", plr)
folder.Name = "leaderstats"
local cash = Instance.new("IntValue", folder)
cash.Name = "Money"
cash.Value = ds1:GetAsync(plr.UserId) or 500
ds1:SetAsync(plr.UserId, cash.Value)
cash.Changed:connect(function()
ds1:SetAsync(plr.UserId, cash.Value)
end)
local function PayCheck() -- Creating a function
local paycheck = script.PayCheck
local teams = game:GetService("Teams")
local payCheckTable = {
["Citizen"] = 120,
["Criminal"] = 150,
["Inmate"] = 0,
["Police"] = 200,
["HeavyGunDealer"] = 225,
["GunDealer"] = 165,
["AdminOnDuty"] = 10000
}
for i, v in pairs(payCheckTable) do
if plr.Team == teams[i] then
paycheck.Value = v
end
end
end
while wait(55) do
PayCheck() -- Triggers our function
cash.Value = cash.Value + script.PayCheck.Value
end
end)
--Thanks BestCreativeBoy

3 comments
I have a similar problem to this, I can't can't get my text GUI to change when your player dies........
cant you get the leaderstats from the player?
also i think using a local script might be unnecessary