Sorry for all the help needed today guys.
I'm making a coin pusher. When someone clicks the insert button (part with a click-detector) it costs them 1 'coin' and the coin is created and dropped.
Here's what I have so far:
Insert = script.Parent
Upgradecost = 1
local ting = 0
function onClicked(click)
if ting == 0 then
check = click.Parent:FindFirstChild("Humanoid")
if check ~= nil then
local user = game.Players:GetPlayerFromCharacter(click.Parent)
local stats = user:findFirstChild("leaderstats")
if stats ~= nil then
local cash = stats:findFirstChild("Coins")
if cash.Value > (Upgradecost-1) then
cash.Value = cash.Value - Upgradecost
script.Parent.Parent.Parent.Purchase:play()
local h = click.Parent:findFirstChild("Humanoid")
if h~=nil then
Coin = Instance.new("Part", game.Workspace)
Coin.Shape = ("Cylinder")
Coin.BrickColor = BrickColor.new("Gold")
Coin.Size = Vector3.new(0.2, 2, 2)
Coin.Position = Insert.Position - Vector3.new(0, 7.7, 0)
Coin.Reflectance = 0.61
Coin.Name = "Working"
Coin.Rotation = Vector3.new(90, 0, 90)
wait(1)
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
end
end
end
end
end
Any ideas? No output or anything.

4 comments
Lines 16-17 are duplicates of lines 7-8. On line 13, use cash.Value >= UpgradeCost. And most importantly, CONNECT THE FUNCTION OUTSIDE OF THE FUNCTION ITSELF. Seriously, I can't stress that enough.
Oh my gosh! Okay I did it. But it still won't work!
Put a print after each if telling what you checked. Then tell us the output
Shouldn't your listener be outside the function...