I recently made a script where when you click on a gun it gets duplicated into your backpack. This is the script i made.
function onClicked()
game.Lighting["Remington 870"]:Clone().Parent = game.Players.LocalPlayer.Backpack
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
But the problem is it works perfectly fine in roblox studio, but when i save and go online it doesn't work. Can someone help me or explain to me why this is happening? Thank you :)

3 comments
I put that code inside of a normal script but nothing happened though?
Try putting the script in ServerScriptService. Also, I recommend putting the shotgun and other stuff that you want to store in ReplicatedStorage.
Still not working