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

Can somebody help me fixing this problem? Attempt to connect failed: Passed value is not a function

Asked by 2 years ago

The code:

function addcash(cash)
    game.Players.PlayerAdded:Connect(function(plr)
        plr.leaderstats.Cash += cash
    end)
end

script.Parent.ClickDetector.MouseClick:Connect(addcash(10))

Error: Attempt to connect failed: Passed value is not a function

1 answer

Log in to vote
1
Answered by 2 years ago

You do not need to make separate function for playeradded

can you try this?

script.Parent.ClickDetector.MouseClick:Connect(function(plr)
      plr.leaderstats.Cash += --Put any amount of cash you want--
end)

have not tested code, tell me if there is any small error

Ad

Answer this question