How can I fire a remote event from a script to a local script

I think I made it pretty clear in the title. All I want to achieve is making my script fire a remote that makes a local script do something. Is there any function for that or anything that could help me do this.

I should mention that my script is firing after a click detector is clicked.

1 Like

Easy. RemoteEventName:FireClient(player, arguments). Add a listening event in a local script. RemoteEvent | Documentation - Roblox Creator Hub

4 Likes

I tried that but I guess I did something wrong, I`ll try again and reply here!

You need one script, one localscript and a remote event object. I would put the remote event in replicated storage so both scripts can see it. I would put the script in serverscriptservice and the localscript in the playerscripts.

Localscript;

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local event = ReplicatedStorage.RemoteEvent
event.OnClientEvent:Connect(function(vlaue)
    print(value)
end)

Server script;

local ClickDetector = script.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local event = ReplicatedStorage.RemoteEvent
ClickDetector.MouseClick:Connect(function(plr)
   event:FireClient(plr,"hi")
end)

Alternatively if you want every client to know about the event you can use :FireAllClients()

5 Likes

Uhm I made it alr but idk who to give the solution to … I knew how to do it but I just did something wrong the first time

Whoever you feel gave you more valuable information that helped who find what you did wrong.

1 Like

Well Someperson was first and he gave me the idea (first) to try fireclient again so I guess he!?

Thanks! Good luck on your game! (Darn, more than 30 chars).

1 Like