The following code is within a LocalScript under an ImageButton in a frame within GUI. The script gives you the gun when you click the image of it and it worked just fine when I tested it in Studio, but when I played the game itself, clicking the ImageButton did nothing.
script.Parent.MouseButton1Down:connect (function() game.ServerStorage.AK47:Clone().Parent = game.Players.LocalPlayer.Backpack end)
Here are two videos I took.
Studio testing: https://www.youtube.com/watch?v=QxBAA_8_cNk&feature=youtu.be In-game testing: https://www.youtube.com/watch?v=ojb4jtCFE8g&feature=youtu.be
Try this instead, i don't know if it will work. Like abnotaddable said, use ReplicatedStorage instead
local gun = game.ReplicatedStorage:WaitForChild('AK47') script.Parent.MouseButton1Click:connect(function () gun:Clone().Parent=game.Players.LocalPlayer.Backpack
I think its becuase connect is depracated, use Connect instead. Plus I think, you should use MouseButton1Click becuase MouseButton1Down is used for holding the left click button.
script.Parent.MouseButton1Click:Connect(function() game.ServerStorage.AK47:Clone().Parent = game.Players.LocalPlayer.Backpack end)