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

How do I use FireAllClients?

Where do I put FireAllClient in this code?

minigames=game.Lighting.Maps:GetChildren()

local g=game.StarterGui.ScreenGui.TextBox

local players = game:GetService("Players")

local numPlayers = players.NumPlayers

wait(3)
while true do
	wait(3)
	if numPlayers>4 then
		wait(3)
		g.Visible=true
		g.Text='Chosing Map'
		ranGame=math.random(1,#minigames)
		gamechosen=minigames[ranGame]
		g.Text='The Round For This Round Will be'..gamechosen.Name
		wait(3)
		gamechosenclone=gamechosen:Clone()
		gamechosenclone.Parent=game.Workspace
		for i=10,1,-1 do
			wait(3)
			g.Text='Time Left'..i
		end
		g.Text='Game Ended'
		wait(3)
		gamechosenclone:Destroy()
	else
		g.Visible=true
		g.Text='There Needs To Be At Least 4 Players To Start'
	end
end


1 answer

In that server code, add to the top

local Event = Instance.new("RemoteEvent",game:service("ReplicatedStorage"))
Event.Name = "Event"

Create a LocalScript, put it in the ScreenGui, and put this:

local RepStorage = game:GetService("ReplicatedStorage")
local Event = RepStorage:WaitForChild("Event")

local GUI = script.Parent
local textframe = GUI:WaitForChild("TextBox")
Event.OnClientEvent:connect(function(text)
	textframe.Text = text
end)

Now in the server script, anywhere g.Text is used, replace it with Event:FireAllClients(text)

4 comments

0

It underlines Event.Name for some reason

0

Forgot to include an extra ) in the first line, sorry

0

It still doesn't show the GUI?

0

1y

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