There is something called StarterGear. When a player respawns it will give the gear to the player that has the gear in StarterGear.
Player = game.Players.LocalPlayer
if Player.Name == "Player" then
local emi = game.Lighting:WaitForChild("Emi")
emi:Clone().Parent = Player:WaitForChild("Backpack")
emi:Clone().Parent = Player:WaitForChild("StarterGear")
end
You should also add this debounce type thing so it doesn't flood your inventory with gear when you respawn.
Player = game.Players.LocalPlayer
if Player.Name == "Player" and not Player:WaitForChild("StarterGear").Emi then
local emi = game.Lighting:WaitForChild("Emi")
emi:Clone().Parent = Player:WaitForChild("Backpack")
emi:Clone().Parent = Player:WaitForChild("StarterGear")
end
Another thing.
This works perfectly fine. As long as it's a local script.
Player = game.Players.LocalPlayer
if Player.Name == "Player" then
local emi = game.Lighting:WaitForChild("Emi")
emi:Clone().Parent = Player:WaitForChild("Backpack")
end
This needs to be a local script since you use LocalPlayer which can only be accessed through LocalScripts.
If this is a regular script, use this code:
game.Players.PlayerAdded:connect(Player)
if Player.Name == "Player" then
local emi = game.Lighting:WaitForChild("Emi")
emi:Clone().Parent = Player:WaitForChild("Backpack")
end
end)
Also, if this doesn't work in studio it's probably because your name is "Player1" not "Player". If you want to do multiple people then use this script. This uses pairs and tables/arrays.
PeopleWhoCanGetGear = {"Player", "Player1", "Someone else."}
game.Players.PlayerAdded:connect(function(Player)
for _,names in pairs(PeopleWhoCanGetGear) do
if Player.Name == names then
local emi = game.Lighting:WaitForChild("Emi")
emi:Clone().Parent = Player:WaitForChild("Backpack")
emi:Clone().Parent = Player:WaitForChild("StarterGear")
end
end
end)
Local:
PeopleWhoCanGetGear = {"Player", "Player1", "Someone else."}
Player = game.Players.LocalPlayer
for _,names in pairs(PeopleWhoCanGetGear) do
if Player.Name == names then
local emi = game.Lighting:WaitForChild("Emi")
emi:Clone().Parent = Player:WaitForChild("Backpack")
end
end
Also LocalScripts must be in a child of Player. So put them in StarterGui or startergear. If it's a regular script just leave it in Workspace.