Do you only want the GUI to display after the part is touched, or after the gamemode is selected?
Thanks! You have made the script more easy and straight forward, but I still have to make sure I understand how the whole process will work.
After the game mode is selected
I originally did not know how to place the GUI into PlayerGUI, thats why I just made a .Touched event.
Ok. Here is a simple way to do it:
Make a RemoteEvent
in ReplicatedStorage
. Make a variable in the server script to hold the event.
Then, after the gamemode is selected, the server will pass that on to the client:
local event = game.ReplicatedStorage.RemoteEvent -- replace with your event
event:FireAllClients(gamemode)
Then, make sure the ScreenGui
with the display contents is parented under StarterGui
. Then, make a LocalScript
parented to the TextLabel
.
local event = game.ReplicatedStorage:WaitForChild("event") -- replace with your event
event.OnClientEvent:Connect(function(text)
script.Parent.Text = text
-- the text variable holds the information sent from the server
end)
You can also control the Visible
properties of all the items if you want it to be visible at different times.
I think this make sense for now. I will give it a try and update you if any issues. Thanks!
Your solution worked but I have a question.
Do I have to place different sets of text labels that will only be triggered after the specific game mode is selected? For instance, upon joining the server the Screen Gui will display āIntermissionā. This will later be changed to the game modeās name. Example: If āMurder Modeā is selected, it will display that specific Text Label, and if āSleep Modeā is selected and vice versaā¦
No. You can use one singular TextLabel
, and one RemoteEvent
. All you need to do is modify your server script to fire a different value, which in this case is your gamemode, down the RemoteEvent
each time.
For instance, when you want it to display āIntermissionā, you would do something like:
--this will go in the part of the script to update the intermission.
local intermission = 20
for i = intermission, 1, -1 do
local textToSend = "Intermission: "..i.." seconds left"
event:FireAllClients(textToSend)
wait(1)
end
and then client side, it will update the intermission each second, because the previous LocalScript
I gave you has been coded in such a way it can be used for multiple things.
Therefore, you can use that RemoteEvent
to change the text of that TextLabel
so that it will show whatever you want it to.
My apologies for the late reply. I believe the issue I am facing now is on my game mode script. Will update you once I discover what my problem is. Thanks.
This is my current understanding of the script, at least my modified version of it.
This local script is parented to the TextLabel in ScreenGui under StarterGui. The Announcement
is an argument in function that consists of āWhatever Text I Want To Sendā
local GUIT = game:GetService("ReplicatedStorage"):WaitForChild("GUI Trigger")
GUIT.OnClientEvent:Connect(function(Announcement)
Announcement = script.Parent.Text
script.Parent.Visible = true
end)
This script is in the Main Script. I intend to place this line of code under all the game modeās script to announce the specific instructions it require the players to do.
local GUIT = game:GetService("ReplicatedStorage")["GUI Trigger"]
MainFloor.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
GUIT:FireClient(player)
end)
My current problem is the Text Label not displaying the text āSay Helloā.
The error message is āUnable to cast value to Objectā
The reason I set it to FireClient
is because at this stage of the game, whoever reaches the platform first will receive the instruction that only that specific player will see first.
The reason that the text is not setting is because you are attempting to store the instance in the Announcement
variable. To set the text, you would need to type script.Parent.Text = Announcement
Oh my bad! Thank you for noticing.
Aight! My issue has been successfully resolved. Greatest of thanks given to you for allowing me to further my understanding in Remote Events!
you can use roblox studio youtube tutorials for understanding more of remote events and other stuff!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.