Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Sword not cloning to player from lighting?

Asked by
fdfxd 50
9 years ago

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)
0
Is this in a LocalScript, and do you have any error messages? dyler3 1510 — 9y
0
Yes it is in a local script, and no, no error messages here.. fdfxd 50 — 9y
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. dyler3 1510 — 9y
0
and... it looked like it was a roblox side problem, and it looks like they fixed it.. fdfxd 50 — 9y
View all comments (2 more)
0
Ah, ok. dyler3 1510 — 9y
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). TheeDeathCaster 2368 — 9y

1 answer

Log in to vote
2
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

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)
Ad

Answer this question