LocalScript isn't detecting remote event FireAllClients()

I want to change a GUI’s Text through the server with a remote event. When the remote event is called, the LocalScript should detect this, but nothing happens. Also, is there any way I can set up a variable in the ServerScriptService script and use it in both scripts?

–Script in ServerScriptService

game.ReplicatedStorage.GUIEvent:FireAllClients()

–LocalScript in the GUI

local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local remoteEvent = ReplicatedStorage:WaitForChild(“GUIEvent”)

local function Intermission()
game.StarterGui.ScreenGui.TextBox.Text = “Intermission”–Want to connect variable from ServerScriptService script here

end

remoteEvent.OnClientEvent:Connect(Intermission)

3 Likes

do:

--Script in ServerScriptService

game.ReplicatedStorage.GUIEvent:FireAllClients('text')

--LocalScript in the GUI

local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local remoteEvent = ReplicatedStorage:WaitForChild(“GUIEvent”)

local function Intermission(text)
game.StarterGui.ScreenGui.TextBox.Text = text–Want to connect variable from ServerScriptService script here

end

remoteEvent.OnClientEvent:Connect(Intermission)
2 Likes

You’re editing game.StarterGui
You would rather want to do this instead:

local Player = game.Players.LocalPlayer 
local function Intermission()
    Player.PlayerGui -- rest of your directory index here
end

It’s more ideal to have your Localscript as the child of your ScreenGui that way you can identify your UI as the script.Parent

StarterGui is a service which is replicated to all clients PlayerGui when they first join.
Let me know if you need more guidance. :smiley:

5 Likes

Would I do something like
text = “Intermission”
for this function?

2 Likes

ok, so basically an argument is something you can send to the client so you’ll put the “Intermission” here:

--Script in ServerScriptService

game.ReplicatedStorage.GUIEvent:FireAllClients("Intermission") -- put whatever you want to send to the client here

--LocalScript in the GUI
local plr = game.Players.LocalPlayer

local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local remoteEvent = ReplicatedStorage:WaitForChild(“GUIEvent”)

local function Intermission(text) -- the text augment is basically whatever you send from the server in this case it's a string "Intermission"
   plr.PlayerGui.ScreenGui.TextBox.Text = text 

end

remoteEvent.OnClientEvent:Connect(Intermission)

plr.StarterGui.ScreenGui.TextBox.Text = text

… should be plr.PlayerGui.ScreenGui.TextBox.Text = text.

Just a heads up! :smiley:

1 Like

you’re right, i’m just not paying attention lol

1 Like

Ohhhh I get it now, let me try this and see if it works

1 Like

The LocalScript still isn’t picking up that the remoteEvent is firing

where is your local script located?

StarterGui–>ScreenGui–>TextBox–>LocalScript

where is the remote event located?

It’s located in ReplicatedStorage–>GUIEvent

Check what errors occur when you have the local script like this:

-- local script
local plr = game.Players.LocalPlayer
local remoteEvent = ReplicatedStorage:WaitForChild(“GUIEvent”)

remoteEvent.OnClientEvent:Connect(function(text)
    print('event fired')
    script.Parent.Text = text 
end)

It’s easier to figure out the problem when i can see the output

No error occurs, just nothing happens.

do you mind if I join your studio to see if i can see what’s wrong in there?

Sure, do I just add you to Team Create?

yeah, my username is paetemc2 (I think you have to friend me on roblox)

Sorry, I’m having issues adding you to Team Create. How do I add you?

friend me on roblox first, then go to this: