So...I'm trying to turn this script into a giver that i can use on a Gui Button. But i cant figure out how i can make the Click function work with a gui button?
Script Below...
local itemname = "Ggs"
local item = game.Lighting:findFirstChild(tostring(itemname))
local trigger = script.Parent
enabled = true
function onClick(plyr)
if plyr.Backpack:findFirstChild(tostring(itemname)) == nil and enabled == true then
enabled = false
trigger.BrickColor = BrickColor.new("Black")
local itemclone = item:clone()
itemclone.Parent = plyr.Backpack
wait(2)
enabled = true
trigger.BrickColor = BrickColor.new("Bright blue")
end
end
script.Parent.ClickDetector.MouseClick:connect(onClick)

2 comments
To correct you, local variables do not need to be used in the specific function you use it in. If it isn't in any 'end needed' functions, then it can be used ANYWHERE. Second, your logic is wrong. plyr would be the MOUSE not the actual player, and anyway, 'LocalPlayer' isn't declared! It's supposed to be 'game.Players.LocalPlayer'.
Sorry. I wrote this at 11:00 PM