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

What did i do wrong with this script?

Asked by 8 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

Output is 23:32:29.768 - Workspace.IronPrinter.Printer.Main.Collect.Collect:3: attempt to index local 'onButtonClicked' (a nil value)

Its inside a surface gui and i dont know what i did wrong

script.Parent.MouseButton1Click:connect(function(onButtonClicked) script.Parent.Sound:Play() local player = game.Players:GetPlayerFromCharacter(onButtonClicked.Parent) local leaderstats = player:WaitForChild("leaderstats") leaderstats.Money.Value = script.Parent.Parent.Parent.Cash.Value + leaderstats.Money.Value script.Parent.Parent.Parent.Cash.Value = 0 end)

0
game.Players:GetPlayerFromCharacter(onButtonClicked.Parent) is not needed. When someone clicks the argument is automatically the Player who clicked it, minikitkat 687 — 8y
0
Would this work? loomis0523BC 0 — 8y
0
game.Players.PlayerAdded:connect(function(player) script.Parent.MouseButton1Click:connect(function() script.Parent.Sound:Play() player:WaitForChild("Backpack") player.leaderstats.Money.Value = player.leaderstats.Money.Value + script.Parent.Parent.Parent.Cash.Value script.Parent.Parent.Parent.Cash.Value = 0 end) end) loomis0523BC 0 — 8y
0
^ don't post answers or a script in the comments, please Tesouro 407 — 8y

Answer this question