Should I split this single event server sided script into multiple events?

The code above works without the if and elseif statements because the server can’t check if the client meets the conditions I outlined in the statements. This used to be all part of a client-sided script (I write things there before I decide what to make server or client sided), so I know all of this works. There’s no error in the code, it just doesn’t do anything - it fires the event but it seems to not do anything since it can’t determine whether the statements are true or false.

I’m considering writing the conditional if statements on the client with their own server sided events. My question is, is this the most efficient thing to do or is there a better way to go around it? I don’t know if this will impact performance relevantly or not.

not completely sure if this is what your asking but, what I like to do personally when I have conditions that the server cant check is just send a string in a parameter telling the server what’s going on, Something like this:

Local Script:

local Parameter

if Condition1 then
        Parameter = "Condition1"
        Remote:FireServer(Parameter)
elseif Condition2 then
        Parameter = "Condition1"
        Remote:FireServer(Parameter)
end

Script:

Remote.OnServerEvent:Connect(function(player, Parameter)
        if Parameter == "Condition1" then
                --Do a thing that should happen if condition 1 is sent
        elseif Parameter == "Condition2" then
                --Do a thing that should happen if condition 2 is sent
        end
end)
1 Like

Yea, this is exactly what I was asking about. This helped reduce the clutter a ton on the server-side script, I only needed 1 function instead of 3. Thanks!

1 Like