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

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

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

✓ Accepted answer

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

2 comments

2

You should explain what you just did, and explain what the pairs function is.

0

I will.

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