I would like this script to work every time its touched, but it doesn't seem to. It only seems to work until Hay.Transparency == 0 on line 18. Please help me, thanks!

moneyToGive = -25
debounce = false
script.Parent.Touched:connect(function(hit)
	if debounce == true then return end
	player = game.Players:GetPlayerFromCharacter(hit.Parent)
	if player == nil then return end
	stat = player:findFirstChild("leaderstats")
	if stat == nil then return end
	cash = stat:findFirstChild("Cash")
	if cash == nil then return end
	debounce = true
	if cash.Value < 0 then
		script.Sound2:Play()
		wait(2) print "line 14"
		debounce = false --Forgot to disable debounce here
	end
	if cash.Value >= 0 then
		if game.Workspace.Desperado.Body.Hay.Transparency == 0 then
			script.Sound2LPlay()
			return end
	end
	if game.Workspace.Desperado.Body.Hay.Transparency == 1 then
		cash.Value = cash.Value + moneyToGive
		game.Workspace.Desperado.Body.Hay.Transparency = 0
		print "Line 20"
		script.Sound:Play()
		game.Workspace.Desperado.Body.Cash20l.BillboardGui.Enabled = true
		wait(3.5)
		game.Workspace.Desperado.Body.Cash20l.BillboardGui.Enabled = false
		wait(2)
		debounce = false
	end
end)

5 comments

0

Free model isn't it? If you coded this yourself you'd know why.

0

If he's modifying a free model, he could benefit from it. That's how I began to learn, incapaz.

0

me too, however OP shouldn't post free models if so.

0

All my scripts are made by me, with the only exception of the help I have aquired from this website. Anway, so would someone please help or not.

0

Btw this is probably to specific to find a free model for.