I do not get an error when using it all that happens is the text value of a surface gui doesn't change

local players = game:GetService("Players")
local debounce = false

script.Parent.Touched:Connect(function(hit)
	local object = hit.Parent
	local text = script.Parent.Parent.ValueToCollect.Value.NumberValue.Text
	local value = tonumber(script.Parent.Parent.ValueToCollect.Value.NumberValue.Text)
	if debounce == false then
		debounce = true
		if object then
			if object:FindFirstChild("Humanoid")then
			text = "0"
			 local player = players:GetPlayerFromCharacter(object)
			 player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + value
			end
		end
		wait(1)
		debounce = false
	end
end)

3 comments

0

no, doing that is counterproductive

0

the reason the surface gui text doesnt change is that you never edited the text property of the gui, you only get the text of the gui and didnt set it

0

the numbervalue is the text