when my player touches this gun he should get it, and it works perfectly in Roblox studio but when I try it in an actual Roblox server I get this error
Workspace.Part.Script5: attempt to index field 'Local Player' (a nil value)
this is my code
local object = game.ServerStorage.Pistol local CloneObject = object:Clone()
local function onTouch(hit) CloneObject.Parent = game.Players.LocalPlayer.Backpack print('hi') end
script.Parent.Touched:connect(onTouch)

2 comments
How does it know what you want LocalPlayer to be?
You need a local script. You can't get to a local player through a normal script.