Can you fire a remoteevent from a local script to another local script?

Is it possible?

2 Likes

Well that’s pretty straight-foward. BindableEvents / Functions can work between LocalScripts as well as ServerScripts, both LocalScripts will just need a reference to the same BindableEvent. I would insert it into ReplicatedStorage, so that LocalScripts can access it easily.

Here is an example where one LocalScript gives another LocalScript a message to print out:

-- LocalScript 1
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local bindableEvent = ReplicatedStorage:WaitForChild("BindableEvent")
bindableEvent:Fire("Hello, world!")
-- LocalScript 2
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local bindableEvent = ReplicatedStorage:WaitForChild("BindableEvent")

local function OnEvent(message)
    print(message) --> Hello, world!
end

bindableEvent.Event:Connect(OnEvent)

API reference for the BindableEvent

2 Likes

i placed two local scripts in starterpack and a bindable event and when i went to test it printed nothing :confused:

Where did you put the BindableEvent?

1 Like

replicated storage

Did you name it “BindableEvent” or just “Event”?

1 Like

BindableEvent
if it was named Event it woudlve just say InfiniteYield


Works fine for me. You probably did something incorrect.

3 Likes

i forgot the task.wait xd

1 Like

I believe it is partly my fault since I didn’t specify the event won’t connect instantly. If you are not firing it immediately then you can leave out the task.wait().

2 Likes