Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

What do I use instead of FireServer()?

FireServer() can only be called from the client, so what do I use if the server is calling the remote event? Here's a chunk of the code :

while true do--the game loop
wait(1)
local ShowGui = game.ReplicatedStorage.OpenGui--the remote event
ShowGui:FireServer()--fire the remote event(but what goes here instead?)

If I didn't explain it well enough, the script that is inside the workspace is trying to fire a remote event but it doesn't fir because it's the server trying to call it rather than a client. What do I use instead of FireServer() that the server can use? Other server script(in SSS) :

local ShowGui = game:GetService("ReplicatedStorage").OpenGui
ShowGui.OnClientEvent:Connect(function(player)
for _,plr in pairs(game.Players:GetPlayers()) do

game.ServerStorage.GUI.Regen:Clone().Parent = plr.PlayerGui
    
	end
end)

3 comments

0

:FireClient(playername, arg) and .OnClientEvent(arg) or :FireAllClients(arg), .OnClientEvent(arg)

0

Can I leave the argument blank?

0

Yeah. The args are Variants, which means they can be nil (blank) as well as anything.

1 answer

✓ Accepted answer

The best thing to use is FireAllClients. For example, If I wanted to change a textbox for all players in a GUI, I'd do this: Server Script:

local RemoteEvent = game.ReplicatedStorage.Event

local text = {
 'Hello!',
 'Hi!'
}

RemoteEvent:FireAllClients(text[1])

Local Script:

local RemoteEvent = game.ReplicatedStorage.Event
RemoteEvent.OnClientEvent:Connect(function(text)
	script.Parent.Text = text			
end)

I suggest reading this wiki page. Hopefully this helped you, and if it did please accept my answer as it helps both of our reputation!

7 comments

0

The second script that's activated when the event is fired is a server script in SSS. Where should I move it and does it have to be a local script?

0

The first script I provided goes into a regular script in the SSS. The second script I provided goes in a localscript in the GUI, or the client.

0

The gui is in serverstorage so would it still work if I put the local script in there?

0

It would work as long as the Gui is cloned into the PlayerGui. I just gave you an example on how they work.

0

Now the remote event parts of it are not working at all with no output errors, is it because of FE or did I do something wrong? The local scripts are inside the gui that will get cloned into player gui, like you said.

0

Where is the fist script located?

0

Workspace, should I move it to SSS? The rest of the script works fine if it helps.

This discussion is preserved as it was. New answers, comments, and votes are closed.