How do I change a GUI's text

(Sorry if this post is really short because I’m being impatient right now.)

I’m trying to make a story/objective board on the side.
I need someone to help me and please make it simplified but also make it easy to read.

Since my game starts with someone hitting the “join” button on the side and gives them time to join the match I had to use a remote event to trigger wave one. I hope this is taken into consideration because I really don’t want to rescript my current wave.

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,3,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
	end
	wait(90)
	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)

Thanks,

– Luke

I’m really confused as to what you want to do. Do you want a GUI to say the current wave number, with the remaining zombies? You can use a RemoteFunction to call and return the value from the server if you have a lot of zombies, or if you want more precise and less polling results you can just fire the value to the client with a RemoteEvent.

If however you want certain text to pop up once the player has reached X zombies killed then you can just make a value which stores the zombies killed and then fire a remoteEvent with the text or you can use a separate module to store all the data.

However, I’d just like to mention that you’re really over-engineering your code. You don’t have to make a separate function for each wave, instead you can make 1 function, i.e. Wave Handler and just input the data needed for that wave.

I know about the over-engineering part, I’m really bad at programming. But I’m trying to display the story/objective on a side panel

For example, image

You can fire a RemoteEvent whenever the UI needs to be updated with the current progress, and you can either choose to put the data straight into the Event so it’ll be a parameter or you can fetch the data from a module you use for data. For example, you’d either do:

<REMOTE>:FireClient(player, "Better be careful, this doesn't look...")

or, alternatively

<REMOTE>:FireClient(player, obj)

(obj within that would represent the stage for the dataModule which can then be sourced via the local script)

Thanks for the quick replies, really means a lot. But I don’t necessarily know what that means :sweat_smile: Like is this a separate script? Is it a local script? Where is it? If its a local script what do I say on the server?

What he’s saying is use the remote events to send over the text from the server to the players to make it show on their screen…

--Server Script
local Text = "Random Text"

RemoteEvent:FireAllClients(Text)
--(Clients being the all players | Use :FireClient(PlayerInstanceHere,Text) for just one player.)

---Local Script
RemoteEvent.OnClientEvent:Connect(function(ServerText)
Gui.Text = ServerText
The gui text will now show "Random Text" (without the quotes) on the gui on the player's screen. 
end)
1 Like

What he’s saying is use the remote events to send over the text from the server to the players to make it show on their screen…

--Server Script
local Text = "Random Text"

RemoteEvent:FireAllClients(Text)
--(Clients being the all players | Use :FireClient(PlayerInstanceHere,Text) for just one player.)

---Local Script
RemoteEvent.OnClientEvent:Connect(function(ServerText)
Gui.Text = ServerText
--The gui text will now show "Random Text" (without the quotes) on the gui on the player's screen. 
end)[Remote Event Documentation](https://developer.roblox.com/en-us/api-reference/class/RemoteEvent)

Check below for the documentation on Remote Events
Remote Events Documentation

1 Like