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

How do I make a surface GUI tool giver?

Asked by 6 years ago

I have this Surface GUI script here, that I can't get working.

local button = script.Parent
plr = game.Players.LocalPlayer
tool = game.Lighting("AK-47")

function onClick()
tool:Clone().Parent = plr.Backpack  
end


button.MouseButton1Click:connect(onClick)

Any kind of help will be greatly appreciated.

0
What is script.Parent? Add the explorer window. DaWarTekWizard 169 — 6y
0
Make sure your GUI is inside the player's gui, else it won't recognize their input. Also, don't forget to set the gui's adornee to your desired part. Le_Teapots 913 — 6y
0
Script.Parent is a TextButton robinbobartur 7 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago
local button = script.Parent
plr = game.Players.LocalPlayer
tool = game:GetService("Lighting")["AK-47"]

function onClick()
    tool:Clone().Parent = plr.Backpack  
end


button.MouseButton1Click:Connect(onClick)

You forgot that Lua's naming system uses square brackets and not parenthesis.

0
Hmmm... DeceptiveCaster 3761 — 6y
0
Never mind, I got it to work. Thank you! robinbobartur 7 — 6y
0
Oh, it must've been that the Character holds the Backpack and not the Player. Was that it? DeceptiveCaster 3761 — 6y
Ad

Answer this question