Event.OnServerEvent:Connect(function(PlayerWhoActivated)
-- The object to clone from. You might want to get this from ReplicatedStorage instead.
-- local tool = game:GetService("ReplicatedStorage"):WaitForChild("Flashlight")
local tool = PlayerWhoActivated.Backpack:WaitForChild("Flashlight")
-- Iterate through each player in the game
for index, player in pairs(game.Players:GetPlayers()) do
-- Clone the tool to each player's backpack if they don't already have it.
if not player.Backpack:FindFirstChild(tool.Name) then
tool:Clone().Parent = player.Backpack
end
-- Make each player equip the tool.
local humanoid = player.Character:FindFirstChildOfClass("Humanoid")
if humanoid then
local tool_to_equip = player.Backpack:FindFirstChild(tool.Name)
if tool_to_equip then
humanoid:EquipTool(tool_to_equip)
end
end
end
end)