Hey there, I have an issue with my cash to collect button. There is not errors.

Here is the script:

while wait(.3) do
	script.Parent.BillboardGui.TextLabel.Text = "Cash to collect : $"..tostring(script.Parent.Parent.Parent.CashToCollect.Value)
end

script.Parent.Touched:Connect(function(Hit)
	local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
	if Player then
		local Human = Hit.Parent:FindFirstChild("Humanoid")
		if Human then
			if Hit.Parent.Humanoid.Health >= 1 then
				if Player and Player == script.Parent.Parent.Parent.Owner.Value then
					local Money = script.Parent.Parent.Parent.Owner.Value:FindFirstChild("leaderstats"):FindFirstChild("Cash")
					if Money then
						Money.Value = Money.Value + script.Parent.Parent.Parent.CashToCollect.Value
						script.Parent.Parent.Parent.CashToCollect.Value = 0
					end
				end	
			end
		end
	end
end)

2 comments

0

Because your loop is holding the thread.

0

Ok.