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)
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!