I am trying to make a game announcement using a Screen Gui that announces what the next selected game mode will be. I am now faced with a problem where I managed to get the ScreenGUI that I cloned from ServerReplicatedStorage to be parented to the PlayerGui in Players, but unable to actually see any of the Gui’s contents.
I am unsure if this method even works. Currently this is the how I envisioned the whole process to be.
Player touches a part that will run the script shown below
Script will place the Cloned “ServerGui” in ServerReplicatedStorage to the PlayerGui in Players
GameMode will be selected and instructions using GuiText will be sent to “ServerGUI”
local MF = script.Parent
local SGUI = game:GetService("ReplicatedStorage")["Local Player GUI"].ServerGUI
local ANTISPAM = {}
MF.Touched:Connect(function(hit)
local playeruser = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if table.find(ANTISPAM, playeruser) then
end
if not table.find(ANTISPAM, playeruser) then
table.insert(ANTISPAM, playeruser)
local CSGUI = SGUI:Clone()
CSGUI.Parent = playeruser.PlayerGui
end
end)
The most efficient way to do this would most likely be to keep the GUI in StarterGui, but set all the transparency properties to invisible. Then, add a LocalScript that will control the text and transparency of the GUI. You can use a RemoteEvent to communicate between the client and the server. This means you could also animate it using the TweenService if you wanted to.
My understanding might be flawed but do correct me if I am wrong.
I have main script that controls the gamemode. Once the Gamemode is randomly selected, it is suppose to send a server wide instruction to every player. I would then update the playerGui using the main script?
if you are right then im not sure why it doesnt show but i usually do this and everything works fine
check if the label has any text input in it or if its transparent or not, otherwise you should try remoteevents like the other person suggested
Am I correct in thinking you only want to update the gamemode text of the TextLabel?
If so, you could use a RemoteEvent and fire the text you want down it to all the clients using the FireAllClients() function. Then, in a LocalScript as a child of the TextLabel, ising that to set the text.
event.OnClientEvent:Connect(function(text)
script.Parent.Visible = true -- This is to make sure that the textlabel is visible and good to go
script.Parent.Text = text
-- The code below is optional if you wanted, it basically sets the textlabel visible to false after a few seconds
wait(3)
script.Parent.Visible = false
end)
Basically, instead of managing all PlayerGui server side, the server will pass the information to the client, and the client will manage the text for only that client. The FireAllClients() function will tell all clients to update the text, therefore making it more efficient and easier to achieve what you are trying to do.
Place ServerGui and Announcemnt Text Label into ScreenGui. (A local script will be placed into Text Label, which contains different functions with predetermined texts that will only connect when the Main Script fires all Clients?)
Do I still retain the .Touched part that is responsible in firing the remote event or do I only allow the remote event to be fired after the selected game mode?