ok so everytime i go in game to test, it constantly says attempt to index and all that, never works - it's for a shop GUI that gives you a gun when clicked
script.Parent.MouseButton1Click:Connect(function()
local RS = game:GetService("ReplicatedStorage")
local item = RS:WaitForChild("GlockDrum")
local player = game.Players.LocalPlayer
local cloned = item:Clone()
cloned.Parent = player.Backpack
end)

1 comment
So today I had the exact same problem and the reason why this was happening was because LocalPlayer does not work in server scripts. I instead used a module script to give it to me.