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

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

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

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)

1 comment

0

I can, and I did..

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