EDIT : The main problem is that the cash.Value (local cash = stats:findFirstChild("Candy") --Get money) gives nil value. The problem with this is that I do have a leaderstat with the Candy as the currency.

What happens is my script passes by the print("Cat") and print("Dog") commands but then it does not pass print("Mow"). I do believe it has something to do with the cash value, correct me if i'm wrong. I have no errors when this happens. Any help?

local ting = 0 --debouncer

function onClick(mouse)
print("Hi")
	if ting == 0 then --debounce check
	ting = 1 --activate debounce
	check = mouse.Parent:FindFirstChild("Humanoid") --Find the human that touched the button
	print("Hillo")

	if check == nil then --If a human is found, then
		print("Hullo")

		local user = game.Players:GetPlayerFromCharacter(mouse.Parent) --get player from touching human
		print("Here")
		local stats = game.Workspace:findFirstChild("leaderstats") --Find moneyholder
		print("Hello")

		if stats ~= nil then --If moneyholder exists then
			print("Cat")
			local cash = stats:findFirstChild("Candy") --Get money
			print("Dog")
			cash.Value  = cash.Value + 3
			print("Mow")
			wait(0.3) --wait-time before button works again
			print("Wof")
		end

	end

	ting = 0 --remove debounce
	end

end

script.Parent.ClickDetector.MouseClick:connect(onClick)

Thanks.

6 comments

0

There has to be an output error for this script.

0

08:01:03.190 - Workspace.Halloween kit.Clickswitch.Script:27: attempt to index local 'cash' (a nil value). It turns out I do have errors, they were just hiding with some of the dialog I told the script to do.

0

Can you post your entire script, the code you provided is not enough for us to help you.

0

Edit your question

0

There.

0

So, does anybody know how to fix this?