In the weapons folder, you put your actual weapons (tools) there. As for that additional code, that’s just an example. If you are using a round system, then that code would be part of the code that starts the round. If you are just placing weapons as soon as the player logs in, you can add it to the PlayerAdded event.
One thing I want to point out is that the big different between this code and just placing the weapon in the StarterPack is that the code will equip the weapon to the player while just placing it in StarterPack will just have the weapon in the player’s inventory.
What your talking about is a killfeed, you can just use a parent frame and have a uilistlayout handle where to place the killbar template, and whenever a player/ npc dies to another player or dummy you can just use a remote event to :FireAllClients() and send the killer’s name/ victims name
If you are manually spawning the players, then you would place that extra code in the player.CharacterAdded event so the code will run when the player physically spawns in the game and is rendered by the engine. Due to timing constraints, which if not observed, can run the risk of a race condition. So when that event fires, I would look for the Humanoid using a WaitForChild function instead of a FindFirstChild. You will need to use the time parameter of WaitForChild. If you don’t, then it’s considered an infinite wait and will throw a warning in the console. Once that’s done, and it’s not nil, then that code can run.
Something like this:
player.CharacterAdded:Connect(function(char))
local human = char:WaitForChild("Humanoid", 10)
if human ~= nil then
for _, player in pairs(playerService:GetPlayers())
equipWeapon(player, weaponName)
end
end
end)
That code might not be correct since I’m doing this on the fly from memory.
As to your other question about where you put the folder, you place the weapons folder in ServerStorage. Do not place it in replicated storage because then the client will have access to your tools and might find a weakness in your code that can be exploited.
I would place it in a module script under ServerScriptService. In fact, I would place it under this script (straight server script, not a module script):
--
-- Loads all the library modules so they are available
-- everywhere on the server.
--
for _,module in pairs(script:GetChildren()) do
local loadMod = coroutine.create(function()
require(module)
end)
coroutine.resume(loadMod)
end
This script goes directly into ServerScriptService. Then all other module scripts go under this. What this script does is that it loads all the module scripts under it and starts them off, each in their own thread, to make better use of the multithreading and multiprocessing hardware on the server.