Will function run in Remote Event function

I was wondering if a function inside a Remote Event function if the function’s condition was met after the remove event function ran.

For example:

 RemoteEvent.OnClientEvent:Connect(function()
print("Event Fired")
Humanoid.Died:Connect(function()
print("Died")
end)
end)

Would the Humanoid.Died function run if the character died long after the remove event was fired?

Yes that will work, but I think there’s probably a better way to organize or structure your code depending on what you expect to happen

1 Like

One more question, if the event is fired again before the Humanoid.Died function is ran, when you die will the function run in the old remove event function run, or will it be overwritten by the new one

They’ll both run. That’s part of why I say you should probably structure it differently. Kinda like this.

local remoteEventArgs = {}

Humanoid.Died:Connect(function()
    -- do whatever with remoteEventArgs but realize they will be nil if the event hasn't been fired yet
end)

RemoteEvent.OnClientEvent:Connect(function(...)
    remoteEventArgs = {...} -- this is valid syntax in case you didn't know, it will take any arguments the remote event receives and put them into the table
end)

Well, I want them to both run though.

I mean they both will. What are you trying to do with this specifically?