Local Script to send information to another Local Script

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve?
    For the game that I have been developing, I am making an arrest system (for a police-esque game). I am developing an arrest system that will have numerous features for what you can do with your detainee. I made a feature that allows for searching, but it first asks for the consent of the other player being detained. Upon them clicking yes, I want the local script inside of the arrest tool to know that the detainee said yes and show the detainee’s inventory.

  2. What is the issue?
    I have been trying to have the officer’s arrest tool local script read the decision made by the detainee and act upon it.

  3. What solutions have you tried so far?
    I have tried to create a RemoteEvent but cannot seem to transfer the information from the local script inside the GUI button from the detainee to the officer’s arrest tool local script.

I have the officer’s arrest tool local script fire an event that gives the detainee a GUI. I just don’t know how to send the decision of the detainee (Yes/No) and give a response back to the officer’s GUI.

Well, you can use a bindable, but I would use a remote function.
Player Pressed Yes --> Send Remote Function to Server to retrieve inventory --> Then update the client accordingly

Then if you want to send it to another local script (I would personally use module scripts) but you can use a bindable and then fire that and have it connect to the local script that you want the information on.

2 Likes

You can use a BindableEvent or BindableFunction which sends data between Scripts

Instead of crossing Server / Client boundary like a RemoteEvent and RemoteFunction

Example:

local BFunction = game.ReplicatedStorage.BindableFunction

BFunction.OnInvoke = function()

end

Other Script:

local BFunction = game.ReplicatedStorage.BindableFunction
BFunction:Invoke()

As @TheDCraft Stated, its probably better to use a ModuleScript

2 Likes
  1. Officer wants to search someone. Send information to the server: the target
  2. Server sends the name of the officer to the target player and the UI pops up.
  3. When the target clicks yes or no, it fires the result (1 = yes, 0 = no, or use boolean) along with the name of the officer which should have been provided by the server in step 2.
  4. Server sends the result to the officer.

What’s the problem? What information are you trying to transfer?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.