Touch to get cash not working!

Try this
Just Make a script in ServerScriptSevice and paste the code

local cashPart = workspace.CashPart
local debounceLength = 10
local cashToAdd = 500
local debounceTable={}
local function isInCooldown(plr)
	local toRet=false
	for _,v in ipairs(debounceTable) do
		if v==plr then
			toRet=true
		end
	end
	return toRet
end

game.Players.PlayerAdded:Connect(function(plr)
	local leaderstats = Instance.new("Folder", plr)
	leaderstats.Name = "leaderstats"
	
	local cash = Instance.new("IntValue")
	cash.Name="Cash"
	cash.Parent=leaderstats
end)
cashPart.Touched:Connect(function(p)
	local p=game.Players:GetPlayerFromCharacter(p.Parent)
	if p and not isInCooldown(p) then
		table.insert(debounceTable, p)
		p.leaderstats.Cash.Value+=100
		wait(debounceLength)
		for i,v in ipairs(debounceTable) do
			if v==p then
				table.remove(debounceTable, i)
			end
		end
	end
end)

Thank you so much! It works great, thank you so much man!

2 Likes