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

[SOLVED] Failed to connect, I haven't passed a function? I did tho...

Asked by 5 years ago
Edited 5 years ago

Hey guys, so here I am with another question.. I am currently trying to do a (Local)Script that will update the leaderstats when a Gui Textbutton is clicked.

I basically Connect my 'addPopcorn' function, but apparently I cannot pass additional parameters in the Connect? I need to tho!

local btn = game.Players.LocalPlayer.PlayerGui.popcornClick.button

local leaderstats = game.Players.LocalPlayer.leaderstats



function addPopcorn(amount)

print(typeof(amount))

leaderstats.Popcorn.Value = leaderstats.Popcorn.Value + amount

end





btn.MouseButton1Click:Connect(addPopcorn(1))

Note: I know it may seem useless now, but I will edit the amount number - ignore that. Thanks.

How would I go about passing the "1"? Says it's not a function..?

Thanks in advance, and any help appreciated!

1 answer

Log in to vote
-1
Answered by 5 years ago
Edited 5 years ago
local btn = game.Players.LocalPlayer.PlayerGui.popcornClick.button

local leaderstats = game.Players.LocalPlayer.leaderstats

btn.MouseButton1Click:connect(function(amount)
    print(typeof(amount))
    leaderstats.Popcorn.Value = leaderstats.Popcorn.Value + amount
    --side note, you can't edit leaderstat value from client if workspace.FilteringEnabled is on, you'll have to use RemoteEvents for that part. this is just a fix so you can pass arguments
end)
0
I can, and I did.. Doge_Brigade 94 — 5y
Ad

Answer this question