Howdy, so, in my game, i have multiple weapon tools, such as an axe, a knife, and others, so i tried to avoid exploiders by setting all the important stats into a server script inside serverScriptService
.
The script haves inside a table with all the info, such as Cooldown
, Damage
, and the AnimationsFolder
, each tool should have their own space inside the table:
--=============================[[ SERVICE ]]==============================--
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--=============================[[ FOLDERS ]]==============================--
local Remotes = ReplicatedStorage:WaitForChild("Remotes")
local Animations = ReplicatedStorage:WaitForChild("Animations").Weapons
local ToolInfoRemote = Remotes:WaitForChild("ToolInfo")
--=============================[[ TABLES ]]==============================--
local ToolInfo = {
["FireAxe"] = {
Cooldown = 2,
Damage = 15,
AnimationsFolder = Animations:WaitForChild("FireAxe")
},
["Knife"] = {
Cooldown = 1,
Damage = 15,
AnimationsFolder = Animations:WaitForChild("Knife")
},
}
--=============================[[ FUNCTIONS ]]==============================--
ToolInfoRemote.OnServerEvent:Connect(function(player, Tool) -- Tool, is tool.name from the client
ToolInfoRemote:FireClient(player, ToolInfo[Tool])
end)
here is the client side script
local InfoRemote= ReplicatedStorage.Remotes:WaitForChild("ToolInfo")
local CoolDownTime = nil
local Damage = nil
local AnimFolder = nil
InfoRemote:FireServer(Tool.Name)
InfoRemote.OnClientEvent:Connect(function(toolData)
CoolDownTime = toolData.Cooldown
Damage = toolData.Damage
AnimFolder = toolData.AnimationsFolder
if AnimFolder then
EquipAnim = AnimFolder:WaitForChild("Equip")
IdleAnim = AnimFolder:WaitForChild("Idle")
Slash1Anim = AnimFolder:WaitForChild("Slash1")
Slash2Anim = AnimFolder:WaitForChild("Slash2")
CleanAnim = AnimFolder:WaitForChild("Clean")
end
end)
--=============================[[ ANIMATIONS ]]==============================--
local AnimEquip
local AnimIdle
local AnimSlash1
local AnimSlash2
local AnimClean
local function LoadAnimations ()
AnimEquip = Humanoid.Animator:LoadAnimation(EquipAnim)
AnimIdle = Humanoid.Animator:LoadAnimation(IdleAnim)
AnimSlash1 = Humanoid.Animator:LoadAnimation(Slash1Anim)
AnimSlash2 = Humanoid.Animator:LoadAnimation(Slash2Anim)
AnimClean = Humanoid.Animator:LoadAnimation(CleanAnim)
if TestMode then
print(Tool.name.." Animations Loadded")
end
end
local function StopAnimations ()
if AnimIdle then AnimIdle:Stop() end
if AnimEquip then AnimEquip:Stop() end
if AnimSlash1 then AnimSlash1:Stop() end
if AnimSlash2 then AnimSlash2:Stop() end
if AnimClean then AnimClean:Stop() end
if TestMode then
print(Tool.name.." Animations Stopped")
end
end
so, the issue, when calling the InfoRemote
inside the client, every single tool gets the same info and stats from the table.
So, knife haves Axe Animations
, CoolDown
, and Damage
, i want this to apply individualy for each tool, (every tool having what their own stats).
I tried calling InfoRemote
in a different order.
I tried to change the structure of the table, but honestly idk much about tables on scripting.
My best attemp was calling InfoRemote
when equipping the tool, but this makes so i need to equip it twice to get their own Stats
Tool.Equipped:Connect(function()
InfoRemote:FireServer(Tool.Name)
end)
so, i just got more confused, i can provide the rest of the code if needed