Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What do I use instead of FireServer()?

Asked by
Viking359 161
6 years ago
Edited 6 years ago

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)
0
:FireClient(playername, arg) and .OnClientEvent(arg) or :FireAllClients(arg), .OnClientEvent(arg) abnotaddable 920 — 6y
0
Can I leave the argument blank? Viking359 161 — 6y
0
Yeah. The args are Variants, which means they can be nil (blank) as well as anything. Thundermaker300 554 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

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!

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? Viking359 161 — 6y
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. PyccknnXakep 1225 — 6y
0
The gui is in serverstorage so would it still work if I put the local script in there? Viking359 161 — 6y
0
It would work as long as the Gui is cloned into the PlayerGui. I just gave you an example on how they work. PyccknnXakep 1225 — 6y
View all comments (3 more)
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. Viking359 161 — 6y
0
Where is the fist script located? PyccknnXakep 1225 — 6y
0
Workspace, should I move it to SSS? The rest of the script works fine if it helps. Viking359 161 — 6y
Ad

Answer this question