Hello, i have problem with ClickDetector and MouseClick function. Every 2 sec it'll increase Value by 5 in "CashValue" (NumberValue), which is in "Drop" part and when you'll click on the part, it should add CashValue to your leaderboard cash, but somehow don't work. Tried to check that with print(), but don't even show it. I don't see any error.
Here is script:
wait(10) workspace:WaitForChild("PartStorage") local cashGui = script.Parent.Drop.CashGui local cashValue = script.Parent.Drop.CashValue local clickDetector = script.Parent.Drop:WaitForChild("ClickDetector") while wait(2) do cashValue.Value = cashValue.Value + 5 cashGui.Cash.Text = cashValue.Value.."$" end clickDetector.MouseClick:Connect(function(player) print("clicked") local owner = script.Parent.Parent.Parent.Owner.Value if player.Name == owner then local PlayerMoney = game.ReplicatedStorage.PlayerMoney:findFirstChild(player.Name) PlayerMoney.Value = PlayerMoney.Value + cashValue.Value cashValue.Value = 0 end end)
Any suggestions what's wrong with this script?
wait(10) workspace:WaitForChild("PartStorage") local cashGui = script.Parent.Drop.CashGui local cashValue = script.Parent.Drop.CashValue local clickDetector = script.Parent.Drop:WaitForChild("ClickDetector") while wait(2) do cashValue.Value = cashValue.Value + 5 cashGui.Cash.Text = "$" end clickDetector.MouseClick:Connect(function(player) print("clicked") local owner = script.Parent.Parent.Parent.Owner.Value if player.Name == owner then local PlayerMoney = game.ReplicatedStorage.PlayerMoney:findFirstChild(player.Name) PlayerMoney.Value + cashValue.Value cashValue.Value = 0 end end)
Does that work?