You shouldn't be using a PlayerAdded
event inside of a localscript - localscripts should only be on places replicates to the client e.g. StarterGui, StarterPack, etc..
So, to fix? Make this a server script, put it in workspace, remove the 'player' variable on line 2
, and finally use the player parameter returned from your PlayerAdded event for the definition of the player.
1 | local Sword = game.Lighting.Sword |
3 | game.Players.PlayerAdded:connect( function (player) |
4 | player.CharacterAdded:connect( function (character) |
5 | Sword:Clone().Parent = character |