How to fire event from module script to server script?

i want to fire from module script(serverScriptService) to server script that placed in model.

the fire event placed in the middle of the module script code and i want only the event fire part to work.

please help me. :smiley: :clap:

1 Like

Can’t seem to understand, elaborate please. Are you trying to run a RemoteEvent from a ModuleScript called by a ServerScript?

But, here is some explanation: ModuleScripts act depending on the type of script they are being called by; this means that if you can an ModuleScript from an LocalScript, the code in the module will be ran client-sided, and vice-versa with a ServerScript.

i am tying to run bindable event from a module script to ServerScript that placed in: game.workspace.Model

And what’s the issue? What’s the code you’re using to do that?

i am trying to get the name of the random and then instance new click detector to the clone part of the destroyed part in the second model

Read up on events documentation: Events | Documentation - Roblox Creator Hub

I would generally avoid using bindables unless you absoluetely need to, all of this can be achieved with modules.

1 Like

I never really used BindableEvents, nor BindableFunctions, but I can’t seem to find an issue with the code either. Mind telling if there’s any errors given by the Output?

there is no errors, just the instance not working

you know what i have other question. how can i get the name of the random part. and then put the name in other script and then: if i have the name of the part then i can search in the model the same name and do click detector

Your script is placed under ReplicatedStorage

Similar to serverstorage, scripts in Rep storage don’t fire. You need to put the script into serverscriptservice!

You can find out more on the rep storage here

i need to instance new click detector to the model and this need to happend only after the round started and the model(map) cloned to game.workspace

Then keep the script disabled until it gets cloned into workspace.

still not working. i don’t have any errors just nothing happening only the script changed to enabled

Try having a part with the exact same script enabled on Workspace. See if it fires by having it print something.

1 Like

i tried putting the script that was in the duplicated model to the workspace and i found that in the workspace its working, but when i put it back its not working and no errors

Have it print what the randomitemremove is.
So above the if statement, make it say print(name)

If it prints nothing, then problem is you not defining bindable/ its location. So that’s why it’s not firing.

If it says can’t print nil, then that means you didn’t define it right in the modulescript.

Oh, on that case, ignore my above message. That’s a problem with disabling/ enabling your script.
Have the script check that it’s a descendant of workspace first, before it does any event firing.
Keep it disabled until it becomes a member of workspace. Then enable it, and have it print(“This script is in workspace”)

but my script need to be in that model(inside the model)

i need to set it disabled and when the model cloned to the workspace and then enable the script that inside the model?

Yes. When it’s inside the model it needs to be disabled since you’ve set what event is in the script.
After it gets cloned and placed inside the workspace, you set it to enabled so it has time to load in first.

See if that does anything to help. If not, I suggest having one script in workspace, that controls everything, rather than constantly cloning new ones.