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

How do I make a surface GUI tool giver?

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.

3 comments

0

What is script.Parent? Add the explorer window.

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.

0

Script.Parent is a TextButton

1 answer

✓ Accepted answer
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.

3 comments

0

Hmmm...

0

Never mind, I got it to work. Thank you!

0

Oh, it must've been that the Character holds the Backpack and not the Player. Was that it?

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