Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why MouseClick don't work and won't let me to collect cash from part?

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?

1 answer

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?

2 comments

0

Eh.. i guess, i explained it wrong. The problem is that MouseClick function don't work. I'm clicking on part, but nothing happening.

0

Hm, then idk.

This discussion is preserved as it was. New answers, comments, and votes are closed.