local script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remotes = ReplicatedStorage:FindFirstChild("Remotes")
local tool = script.Parent
tool.Activated:Connect(function()
Remotes.ToolActivated:FireServer()
end)
server script
local Remotes = ReplicatedStorage:FindFirstChild("Remotes")
local tools = ServerStorage:FindFirstChild("Tools")
local scripts = ServerStorage:FindFirstChild("Scripts")
local ToolConfig = require(ReplicatedStorage:FindFirstChild("Config"):FindFirstChild("ToolConfig"))
Remotes.ToolActivated.OnServerEvent:Connect(function(player:Player)
print("ServerFired")
local PlayerTool = player.Inventory.EquippedTool.Value
for tool, ToolTable in pairs(ToolConfig) do
if tool == PlayerTool then
player.leaderstats.E.Value += ToolTable.EPoints
end
end
end)
for i, tool in ipairs(tools:GetChildren()) do
local script = scripts.Click:Clone()
script.Parent = tool
end
on player added local script will be cloned and parented to the tool that the player has in their backpack