Detect if the player leaves or if the character is destroyed via tool script

shouldn’t cause lag if the hitbox is only called once for making and another for destroying not multiple times per second. Actually it would need to only be called once for making because SSS will handle destroying

The hitboxes are called multiple times (they are hitboxes for weapons)

i must say you are handling Hitboxes very weirdly again Spacial queries are normally done on SSS
Another solution is to Make the Module that you are using Accessible to both Tool Script and SSS. i am not really sure what the Module u are using is or what areguments you are giving so i am just giving an educated guess so be patient with me

well, im actually using a module made as a community resource.

Im not sure how this would work, Would there just be a script looping through every single tool to detect when they are activated?

Im not exactly sure how to do that.

Also, im up for changing my hitbox system, but i dont know any that are actually good/what i need.

ok so when a player uses the weapon or uses a skill the event should be fired from client to Server then the Server would Call a Module to perform the Hitbox. the Spatial Query does not or should not need to be Stopped or destroyed unless it is being looped or saved in a table.
in other words Spatial Queries are not an instance they are more of a calculation that the workspace does

So a remote event? Im pretty sure that would lag my game very very badly, since im thinking the max server size would be 30, Therefore 30 hitboxes could be activated at the same time. (30 remote event firings at the same time)

the server will only break when theres like 100,000 remote events being fired at the same time
roblox servers are much mroe powerful than u think

Ive tested before, it starts to lag badly when there are like 20 being fired at the same time.

except for when they go down like all the time

that should not be the case unless you are firing 20 per 0.01 seconds that should not be the case at all. there is something wrong with your server code not the remoteevents. Muchacho Hitbox is very outdated and should not be used

well the weapon cooldowns are all different, Some let you swing with no cooldown.

Anyways, What im trying to say, is that i dont really wanna use remote events.

all games from the most famous to even Shooting games use Remote Events it is how you communicate between client and server. there is something very wrong with your code if 20 is breaking your game

I know, I use remote events for my guns too. All im saying is that i dont wanna use it, I’d have to completely rework all of my tools for it.

When i had that happen, all the event was doing was changing the pitch of a sound, though it was in a runservice render stepped (i didnt know much about stuff back then)

Anyways, I’ll try something else. Thanks for your help though.

local parts = workspace:GetPartBoundsInBox(point_cframe * self.Offset, self.Size, self.OverlapParams)

This is how im calcuating the hitbox, Can i change it somehow to like, parent it to the character or something?

Turn the closure under the tool.Destroying event connection into an actual defined function, e.g:

function DestroyProcess()

Hence, your Tool.Destroying event will look as follows


As a result, we can use the same function for when the player is leaving
  if leavingPlayer.Player == player then  -- Do note, I am not sure if this is a LocalScript or a Server Script so define the variable "player" appropriately where it applies

So that the same exact function is running