How do I change the text of a GUI in a server script?

So, 2nd post of the day :sweat_smile: working on a game and I’m trying to figure out how to change the text of my GUI to tell the player the story and what the objective is.

I looked up why my current attempt isn’t working and apparently I can’t use starter GUI and instead the GUI “folder” inside of the player but I don’t know how to do that. I hope to keep it into one script since the events are staged in it.

local spawner =  game.Workspace.Game.NPCs.City_Battle.Wave_One.Spawner.CFrame
local chapter = script.Parent
local chapters = chapter.Parent
local sw1 = chapter.SpawnWave1
local sw2 = chapter.SpawnWave2
local sw3 = chapter.SpawnWave3
local sw4 = chapter.SpawnWave4
local endevent = chapter.End
local rs = game:GetService("ReplicatedStorage")
local Match_Status = script.Parent.Parent.Parent.Join_Match.Frame.Match_Status.Text -- Variables for the changing text areas
local Storyboard = script.Parent.Parent.Parent.Storyboard.Frame.Story.Text
local function spawnwave1()
	local rope1 = game.Workspace.Game.NPCs.City_Battle.Ropes.Rope1
	local rope = game.Workspace.Game.NPCs.City_Battle.Ropes.Rope
							-- I attempted to make a local script in starter player scripts so I removed all of the text changer parts of the script
	rope.Transparency = 0
	wait(1)
	rope1.Transparency = 0
	wait(1)
	chapters.CanJoin.Value = false
	chapters.MatchInProgress.Value = true
	wait(3)
	for count = 1,20,1 do
	local fast_hacker = rs.Hackers.Fast_Hacker
	local fasthackerclone = fast_hacker["Drooling Zombie"]:Clone()
	local humrootpart = fasthackerclone:WaitForChild("HumanoidRootPart")
	local cframe = game.Workspace.Game.NPCs.City_Battle.Wave_One.Spawner.CFrame
	humrootpart.CFrame = cframe
	fasthackerclone.Parent = game.Workspace.Game.NPCs.City_Battle
	humrootpart.Anchored = false
	wait(90)
	end
	chapters.CanJoin.Value = true
	chapters.MatchInProgress.Value = false
	wait(15)
	chapters.CanJoin.Value = false
	chapters.MatchInProgress.Value = true
end

local function spawnwave2()
	print("Spawnwave2")
end

local function spawnwave3()
	print("Spawnwave3")
end

local function spawnwave4()
	print("Spawnwave4")
end

local function endchapter()
	print("End Of Chapter.")
end


sw1.OnServerEvent:Connect(spawnwave1)
sw2.OnServerEvent:Connect(spawnwave2)
sw3.OnServerEvent:Connect(spawnwave3)
sw3.OnServerEvent:Connect(spawnwave4)
sw3.OnServerEvent:Connect(endchapter)

I would appreciate if someone could figure it out.

Thanks,
– Luke

1 Like

make an event for when the gui is changed, fire the event when you want to change it and use FireAllClients then make a local script for when the event is fired and make it change the text from there, the text will be changed on all players screens at the same time

How would I use just one event? wouldn’t I need an event for every single line?

just make it like

youreventnamehere:FireAllClients(stringvariable)

then

youreventnamehere.OnClientEvent:Connect(function(stringvariable)
text = stringvariable
end)

Which is the local script and which is the server script?

The one with FireAllClients is always a server script, since that’s the only place where it can be fired from.

1 Like

server: fireclient and onserverevent
client: fireserver and onclientevent

I understand that part, but how to do I: Find the player, Where is the local script? How do I find the player? Where do I find the GUI?

game.Players.PlayerAdded:Connect(function(player)
local playergui = player.PlayerGui
end)

local script goes in starerplayerscripts

1 Like

How do I incorporate this into one script that already has an event function?