Can a Event be connected 2 times? [SOLUTION FOUND THX]

hi devforum people,

i have a question as im fiddling around with a security system

so i am modifying this gun script wich is a tool and inside it, it as a gunscritpt local and a gunscript_server scripts.
and there is also a script called VisualizeBulletScript wich is in serverscript service it also works togheter with the gunscript local.

so i am currently making the local gunscript fire events and pass infomation as example
“Player, Tool, and the other stuff wich were in there”

because i want the server scripts to first check if the player even owns the tool and didnt steal it with a local script off other peoples backpack.

However somehow the gun broke after i did these changes and when i even reload it kicks me the orginal owner of the tool.

-- This is a the Visuliazebulletscript in serverscriptservice its a serverscript
local function checkTool(Player, Tool)
    return Tool and Tool:IsA('Tool') and (Tool.Parent:IsDescendantOf(Player) or Tool.Parent:IsDescendantOf(Player.Character))

OBJEDIT.OnServerEvent:connect(function(Player, Object, HandleType, GunType, Tool)
	 if not checkTool(Player, Tool) then -- Do the same check whenever tool needs server to do something. This is the best practice!
        Player:Kick('Invalid Client request')
    -- some server code bla bla

however what also could be good for me if i can just revert these changes and make it so that if the event was fired can it be connected 2 times ? as example the player reloads and by doing that he fires a server event can then 2 different scripts use “OnServerEvent” and they both run code ?

or is there a way for a server script to fire a event so another serverscript catches it ?

Yes, multiple listeners can connect to an event. The callbacks are invoked in the order they were connected, if I remember correctly.
You probably shouldn’t be relying on the order though, since I don’t see any confirmation on the wiki of this behavior so it could change.

You can do this with BindableEvents, which were designed specifically for this use case:

hey thats good can i then do something like
the local script fires a event

then 2 scripts connect however can i do something like that one of the scripts wait for the other one to finish or send confirmation so i can do one script to just do normal gun stuff and the other one to check if the player even owns the tool

You should be checking if the player owns the tool first before doing the gun stuff, I don’t think you need two connections to do this unless the code is in different scripts?
Edit: I see you do use two scripts. Maybe using ModuleScripts makes more sense?

there is already a modulescript its the settings

You can have multiple ModuleScripts in your game :smile:

im not a pro in scipting i used pre scripted stuff and modify them or i rescript stuff i see from roblox tutorials
thats how i currently teach myself scripting

Hm the organization looks a bit messy, looks like some scripts are disabled as well (?)
The easiest way to solve your problem, in my opinion, is to make your Visuliazebulletscript script a ModuleScript, then require it in your Gun Script so you can use the checkTool function.