My paycheck GUI is not working

  1. I want a working paycheck GUI

  2. The paycheck things can pop up but when im trying to collect money it doesnt give it, it just dissapears.

Paycheck script:
image
Leaderstats:
image
Paycheck GUI handler:


Replicated storage:
image
Please help as quick as possible :slight_smile:

1 Like

First, are you getting money? Sorry i can’t understand its confusing

For the

You made it supposed to disappear but it should give the value in the other script anyway

Does this value show on the leaderboard? If not, it could be the time you parented it or Named it because, Leaderstats must be named in lowercase leaderstats

local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player

Change IntValue to NumberValue for the Cash Money Value.

local Players = game:GetService("Players")

local CashDataStore = DataStoreService:GetDataStore("CashData")

local Settings = {
	["CashPerPaycheck"] = 100,
	["TimePerPaycheck"] = 3,
	["DefaultCashValue"] = 0,
	["SaveKey"] = "Player-"
}

local function WaitForPaycheck()
	for i = Settings.TimePerPaycheck, 0, -1 do
		task.wait(1)
	end
end

local function ActivatePaycheck(player: Player)
	WaitForPaycheck()
	
	if player then
		local Leaderstats = player.leaderstats
		local Cash = Leaderstats.Cash

		Cash.Value += Settings.CashPerPaycheck


		ActivatePaycheck(player)
	else
		return
	end
end

local function OnPlayerAdded(player: Player)
	local Leaderstats = Instance.new("Folder", player)
	Leaderstats.Name = "leaderstats"
	
	local Cash = Instance.new("IntValue", Leaderstats)
	Cash.Name = "Cash"
	
	local SaveID = Settings.SaveKey .. player.UserId
	local CashData = CashDataStore:GetAsync(SaveID)
	
	if CashData then
		Cash.Value = CashData[1]
	else
		Cash.Value = Settings.DefaultCashValue
	end
	
	coroutine.wrap(ActivatePaycheck)(player)
end
Players.PlayerAdded:Connect(OnPlayerAdded)

local function OnPlayerRemoving(player: Player)
	local SaveID = Settings.SaveKey .. player.UserId
	
	CashDataStore:SetAsync(SaveID, {player.leaderstats.Cash.Value})
end

game:BindToClose(function()
	for _, v in pairs(Players:GetPlayers()) do
		OnPlayerRemoving(v)
	end
end)

Notes:

  1. If you don’t want the stats to show up on the leaderboard, change the leaderstats’s name to Leaderstats.
  2. If you use this script, the data before will be stored and be not used since I change the data store name CashDataStore instead of before’s. If you don’t want, simply change the cash data store name to Cash.
  3. You can change the settings. (SaveID is the ID format you save the data)
  4. If you have any issues, don’t hesitate to ask me!
1 Like

Also, just use ONE script to do this because yes. :sunny:

no i dont when, it just pops up after 3 minutes and when i click it no money are there

Do what I did, you probably didnt see your leaderboard

Thanks! It worked. (post limit)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.