Hey! so im making a weapon system for my game, my friend told me to use module scripts that works like tools but are inside a folder inside the player, instead of in the tool.
The problem im running at is the player switches tools every round, for example when he is in the lobby he has no tool, but when he is in a match he gets the tool, how would i make the modules work for that?
Thanks in advance
You can make a different module which handle each different tools, just name the module as the same tool name heβs handling, then by using a Script in ServerScriptService, you can check when a tool is added in character and require the right module.
Here is an example:
--//Services//--
local PlayerService = game:GetService("Players")
--//Functions//--
local function ToolActivated(Tool)
local Module = script:FindFirstChild(Tool.Name)
if Module then
coroutine.resume(coroutine.create(function()
require(Module).Activated()
end))
end
end
local function ToolsCheck(Character)
Character.ChildAdded:Connect(function(Tool)
if Tool:IsA("Tool")then
Tool.Activated:Connect(function()
ToolActivated(Tool)
end)
end
end)
end
--//Connections//--
workspace.ChildAdded:Connect(function(Character)
if Character:IsA("Model")and PlayerService:FindFirstChild(Character.Name)then
ToolsCheck(Character)
end
end)