Not Local script but a Game script. So not like:
g = game.ReplicatedStorage.LinkedSword:Clone()
g.Parent = game.Players.LocalPlayer.Backpack
So how would I give everyone in the game a linked sword from the Replicated Storage with only 1 script?
Not Local script but a Game script. So not like:
g = game.ReplicatedStorage.LinkedSword:Clone()
g.Parent = game.Players.LocalPlayer.Backpack
So how would I give everyone in the game a linked sword from the Replicated Storage with only 1 script?
Heres a better version of the person's answer.
#- Steps :
[1] : Make a table of game.Players so its userdata/
[2] : Clone the Sword from the service/
[3] : Parent the new object
for i, v in pairs( -- in pairs is a basicly a table explorer.. it will get the table
game.Players:GetChildren() -- in this case :GetChildren() creates a table ( {} <-- )
) do
local NewObj = game:GetService("ReplicatedStorage").LinkedSword:Clone() -- we clone the object
-- So that the original object doesnt remove itself and your NOT able to clone it again
NewObj.Parent = v.Backpack -- the "v" is the player so v.Backpack reparents the cloned object to the correct parent
end
for i, v in pairs(game.Players:GetChildren()) do
g = game:GetService("ReplicatedStorage").LinkedSword:clone()
g.Parent = v.Backpack
end
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
You should explain what you just did, and explain what the
pairsfunction is.I will.