I'm familiar with code but not enough to write it out as if I knew the language fluently, so I had some help creating this script for ServerScriptService:
local tools = {game.ServerStorage.VEnforcer} local admins = {Doom10000=true} game.Players.PlayerAdded:connect(function(p) if admins[p.Name] then local backpack = p:WaitForChild("Backpack") for i,v in ipairs(tools) do v:Clone().Parent = backpack end end end)
It allows a character to spawn with the appropriate tool assigned, but upon death, it is removed. I tried altering it to put the tool in the backpack through StarterGear but it doesn't work out.
If someone could help explain how to do this, with or without elaboration on the coding itself, would be very appreciated!
local tools = {game.ServerStorage.VEnforcer} local admins = {Doom10000=true} game.Players.PlayerAdded:connect(function(p) if admins[p.Name] then local backpack = p:WaitForChild("Backpack") p.CharacterAdded:connect(function() for i,v in ipairs(tools) do v:Clone().Parent = backpack end end end) end)
try to see if it works this time
Do this:
local tools = {game.ServerStorage.VEnforcer} local admins = {Doom10000=true} game.Players.PlayerAdded:connect(function(p) if admins[p.Name] then local backpack = p:WaitForChild("Backpack") p.CharacterAdded:connect(function() for i,v in ipairs(tools) do v:Clone().Parent = backpack end end end end)
The character added function makes it do this everyone a player's character spawns.
It's fixed.
Here's the code that makes it work:
local tools = {game.ServerStorage.VEnforcer} local admins = {Doom10000=true} game.Players.PlayerAdded:connect(function(p) if admins[p.Name] then p.CharacterAdded:connect(function(c) local backpack = p:WaitForChild("Backpack") for i,v in ipairs(tools) do v:Clone().Parent = backpack end end) end end)
Credit to Warspyking for the code.