Gui Button not giving tool

I am trying to make a button give a tool, but it’s not working. I tried scripting, but it still doesn’t work. Please help me.

Code:

local Button = script.Parent
local Cup = game.ReplicatedStorage.Large.Cup
local Player = game.Players.LocalPlayer

Button.MouseButton1Click:Connect(function()
	local CupClone = Cup:Clone()
	CupClone.Parent = Player.Backpack
end)

Is this a local script or a normal script?

1 Like

I am using a local script in the button.

How does the hierachy in ReplicatedStorage look like for the Cup? It could be something related to that. Any errors also?

Button.MouseButton1Click:Connect(function()
    print("Event fired")
	local CupClone = Cup:Clone()
	CupClone.Parent = Player.Backpack
    print("Gave "..Player.Name.." the tool") 
end)

Try this and see what outputs?

Output:

The flipping heck what

Why’d you put it inside ServerStorage instead of ReplicatedStorage? The client won’t be able to see Objects inside there

1 Like

Thank you! It worked!

Random Text

2 Likes

Np, also just to clarify here:

ServerStorage is not accessable across ROBLOX’s client/server boundaries, what I mean by that is

Imagine I put a Orange inside a Tree, now if I’m a person just walking along I’m only able to see the Tree, but not the Orange

ReplicatedStorage can be accessed by both the client & server :slightly_smiling_face: