I’m creating a tool for a melee weapon in my game. It works perfectly fine, however, if a player were to spam equip the tool, the memory usage shoots up (from a normal 300Mb to 1kMb) and lags the server.
I’ve tried putting a debounce into the .Equipped event because I thought it was the Animation loading, but it still persisted. There isn’t really anything too intensive in my code either, as far as I know.
Code: (client)
Tool.Equipped:Connect(function()
if db == false then
db = true
IdleAnim:Play()
Tool.Activated:Connect(function()
if cooldown == false then
cooldown = true
UseAnim:Play()
UseEvent:FireServer()
wait(2.5)
cooldown = false
end
end)
db = false
end
end)
It only happens when players equip it, not when players use it. This happens with all the other tools in my game as well. I also tried disconnecting the .Equip event, but it just stopped it from working. I’m confused on why it’s lagging so much.