Hello,

I'm working on a GUI that gives a tool, but I'm running into a little issue. I have a click-detector in a part version that works perfectly. Upon clicking, the item is inserted into the backpack and is able to be equipped without issue --See here: (screenshot: [https://prnt.sc/kut9uk] )

*Filtering is enabled.

In my GUI version however, everything works smoothly until the item is equipped. When the item is equipped using the GUI method, THIS happens: (screenshot: [https://prnt.sc/kut9la] )

I'm looking for a solution to this. I want the GUI version to be able to deliver the tool into the player's backpack nicely, how the click detector version does. I'll put the code for both of them below. Please help me out if you can, thank you!

Gui Version:

local p = game.Players.LocalPlayer 
local button = script.Parent
local backpack = p.Backpack
local tool = game.ReplicatedStorage:WaitForChild("Cup") 

button.MouseButton1Click:connect(function()
        local nTool = tool:Clone()
        nTool.Parent = backpack
    end)

ClickDetector Version:

local itemname = "Cup"	
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

0

I believe this is due to filtering enabled. You will need to fire the server to give the tool. Expanded more here: https://wiki.roblox.com/index.php?title=Remote_Functions_%26_Events

0

@BunicornBoy, thank you for pointing me in the right direction! By looking at the information from that page, I was able to figure it out myself.