So I am trying to make a gui frame that comes up when an admin says ':start', this part works.. after that I want the right side of the frame to change to the home team logo and color, and the left side to change to the away team logo and color.
It does not change the logos and color when I test it in game.
In Explorer Layout image you will see a few scripts, the only one that matters are StartScreen>LeftLogo>Logo>LocalScript code:
for i,v in pairs (game.Teams:GetDescendants()) do if v.Name == "away" then if v:IsA("BoolValue") then script.Parent.Image = v.Parent.Logo.Decal.Texture script.Parent.Parent.Parent.Frame.LeftBackground.BackgroundColor3 = v.Parent.RGB.Value end end end
then the right side of the frame: StartScreen>Frame>RightLogo>Logo>LocalScript
for i,v in pairs (game.Teams:GetDescendants()) do if v.Name == "home" then if v:IsA("BoolValue") then script.Parent.Image = v.Parent.Logo.Decal.Texture script.Parent.Parent.BackgroundColor3 = v.Parent.RGB.Value end end end
game.Teams:GetDescendants() picture
Appreciate your time please help!
So, the first thing we need to determine is if the chat command is set up and hooked to the client properly. Seeing as how I know a little about how your game works already, I think I'll be able to help the most.
The :start
command is handled on the server. You need to fire the client using RemoteEvents when the :start command actually does something. You can technically do this on the client's side, but since you already have a script that checks if the speaker is an admin or not on the server, using a RemoteEvent with :FireAllClients() will be best
Now, lets set some things up. You'll have to create a new LocalScript in StartScreen and delete the scripts in both the logo ImageLabels. Handling this in one script is much more convenient for our use case.
1 - Create a RemoteEvent in game.ReplicatedStorage
and name it "StartingGuiEvent"
2 - In the place where the :start
command is, you'll have to put this code in
local ClientStartingGuiEvent = game:GetService("ReplicatedStorage"):WaitForCild("StartingGuiEvent") ClientStartingGuiEvent:FireAllClients(workspace.HomeTeam.Value, workspace.AwayTeam.Value) -- // This is where my insider knowledge comes in handy, lol. The `:awayteam` and `:hometeam` commands set both of these values for us. Even if they come back as nil, that's okay because we'll search for them on the client again.
3 - And now we have to receive that RemoteEvent fire in the client. This will be in the LocalScript you created that is inside of StartScreen
local StartScreenGui = script.Parent local RightLogoFrame = StartScreenGui.Frame.RightLogo local LeftLogoFrame = StartScreenGui.LeftLogo local function UpdateTheVersusGui(HomeTeam, AwayTeam) print("Client - Updating the versus gui") HomeTeam = (HomeTeam) or (workspace.HomeTeam.Value) -- // This handles if the server sent us a nil value AwayTeam = (AwayTeam) or (workspace.AwayTeam.Value) -- // ^ if (not HomeTeam) then -- // If we still haven't decided what the home team is repeat -- // Wait until the home team value has been set wait(.5) until (workspace.HomeTeam.Value) HomeTeam = (workspace.HomeTeam.Value) end if (not AwayTeam) then -- // If we still haven't decided what the away team is repeat -- // Wait until the away team value has been set wait(.5) until (workspace.AwayTeam.Value) AwayTeam = (workspace.AwayTeam.Value) end print("Client - Both teams have been set, updating the GUI now") RightLogoFrame.Logo.Image = HomeTeam.Logo.Decal.Texture LeftLogoFrame.Logo.Image = AwayTeam.Logo.Decal.Texture RightLogoFrame.BackgroundColor3 = HomeTeam.TeamColor.Color -- // .Color of BrickColor values is an easier method than using .RGB.Value (I think? Not certain) LeftLogoFrame.BackgroundColor3 = AwayTeam.TeamColor.Color end game:GetService("ReplicatedStorage"):WaitForCild("StartingGuiEvent").OnClientEvent:Connect(UpdateTheVersusGui)
4 - Test it! I didn't use the method of finding the BoolValue
objects in the Team
objects, but I think this way will work because you are setting workspace.HomeTeam.Value to the home team anyway (as well as the away team).