here is the code:
local sound = script.Parent.Money
local cost = 0
script.Parent.Touched:Connect(function(hit)
if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
if _G.Money >= cost then
sound:Play()
Instance:Remove(script.Parent)
end
end
end)
heres the money variable:
local Players = game:GetService("Players")
local function leaderboardSetup(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Money = Instance.new("IntValue")
Money.Name = "Money"
Money.Value = 0
Money.Parent = leaderstats
end
-- Connect the "leaderboardSetup()" function to the "PlayerAdded" event
Players.PlayerAdded:Connect(leaderboardSetup)

2 comments
You are getting this error because _G.Money does not exist.
Are you sure u have " _G.Money" as an variable if u have and still have this error u could try and warp in tonumber()