Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago

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

Log in to vote
0
Answered by 6 years ago
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?

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. karolus1 8 — 6y
0
Hm, then idk. gamerbeeze1 -3 — 6y
Ad

Answer this question