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 :)
game.Players.LocalPlayer
That can only be accessed from a LocalScript. Assuming you aren't using FilteringEnabled, try this in a normal script (still inside the ClickDetector):
function onClicked(Clicker) game.Lighting["Remington 870"]:Clone().Parent = Clicker.Backpack end script.Parent.ClickDetector.MouseClick:connect(onClicked)