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

How do I move an item from Replicated Storage to the players backpack?

Asked by
cuff5 10
9 years ago

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?

2 answers

Log in to vote
0
Answered by 9 years ago

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
Ad
Log in to vote
-2
Answered by
saenae 318 Moderation Voter
9 years ago
for i, v in pairs(game.Players:GetChildren()) do
    g = game:GetService("ReplicatedStorage").LinkedSword:clone()
    g.Parent = v.Backpack
end
2
You should explain what you just did, and explain what the `pairs` function is. woodengop 1134 — 9y
0
I will. MessorAdmin 598 — 9y

Answer this question