Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Sword not cloning to player from lighting?

Been trying to figure this out all day, it doesn't seem to be working,

It used to work yesterday, before todays update..

It still works on solo

Sword = game.Lighting.Sword
player = game.Players.LocalPlayer


game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(character)
	Sword:Clone().Parent = player.Character
	end)
end)

6 comments

0

Is this in a LocalScript, and do you have any error messages?

0

Yes it is in a local script, and no, no error messages here..

0

Ok, try this. Go into your game (Not on Studio), and press F9. When the Gui pops up, check on the Local, and Server tab, and tell me if it shows any errors.

0

and... it looked like it was a roblox side problem, and it looks like they fixed it..

0

Ah, ok.

0

Please use the 'ReplicatedStorage' Service, the 'Lighting' service is NOT meant to be used to contain objects in it, other than a Sky, users did this back then, but, Lighting's purpose was not supposed to be used like that, while, ReplicatedStorage does NOT replicate to a Server-Sided script, only a Client-Sided script (LocalScript).

1 answer

✓ Accepted answer

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.

local Sword = game.Lighting.Sword

game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(character)
		Sword:Clone().Parent = character
	end)
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.