Advertisement
HowToRoblox

CTFGuiHandler

Nov 30th, 2022
1,464
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.07 KB | None | 0 0
  1. local rs = game.ReplicatedStorage:WaitForChild("CTFReplicatedStorage")
  2. local config = require(rs:WaitForChild("CONFIGURATION"))
  3. local status = rs:WaitForChild("STATUS")
  4.  
  5. local statusText = script.Parent:WaitForChild("StatusText")
  6. local teamsFrame = script.Parent:WaitForChild("TeamsFrame")
  7. teamsFrame.Visible = false
  8.  
  9. local client = game.Players.LocalPlayer
  10.  
  11.  
  12. function updateStatus()
  13.     if not client:FindFirstChild("FAILED TO LOAD DATA") then
  14.         statusText.Text = status.Value
  15.     else
  16.         statusText.Text = "Your data did not load successfully. Rejoin to fix this issue."
  17.     end
  18. end
  19.  
  20. updateStatus()
  21. status:GetPropertyChangedSignal("Value"):Connect(updateStatus)
  22.  
  23.  
  24. rs.ChildAdded:Connect(function(child)
  25.    
  26.     if child.Name == "SCORES" then
  27.         local team1Flags = child:WaitForChild("TEAM 1 SCORE")
  28.         local team2Flags = child:WaitForChild("TEAM 2 SCORE")
  29.        
  30.         local plrTeam = client.Team
  31.         teamsFrame.Team1Frame.BackgroundColor3 = plrTeam.TeamColor.Color
  32.        
  33.         if plrTeam == config.Team1 then
  34.             teamsFrame.Team2Frame.BackgroundColor3 = config.Team2.TeamColor.Color
  35.            
  36.             teamsFrame.Team1Frame.FlagsCaptured.Text = team1Flags.Value
  37.             teamsFrame.Team2Frame.FlagsCaptured.Text = team2Flags.Value
  38.            
  39.         elseif plrTeam == config.Team2 then
  40.             teamsFrame.Team2Frame.BackgroundColor3 = config.Team1.TeamColor.Color
  41.            
  42.             teamsFrame.Team1Frame.FlagsCaptured.Text = team2Flags.Value
  43.             teamsFrame.Team2Frame.FlagsCaptured.Text = team1Flags.Value
  44.         end
  45.        
  46.         team1Flags:GetPropertyChangedSignal("Value"):Connect(function()
  47.             if plrTeam == config.Team1 then
  48.                 teamsFrame.Team1Frame.FlagsCaptured.Text = team1Flags.Value
  49.             else
  50.                 teamsFrame.Team2Frame.FlagsCaptured.Text = team1Flags.Value
  51.             end
  52.         end)
  53.         team2Flags:GetPropertyChangedSignal("Value"):Connect(function()
  54.             if plrTeam == config.Team2 then
  55.                 teamsFrame.Team1Frame.FlagsCaptured.Text = team2Flags.Value
  56.             else
  57.                 teamsFrame.Team2Frame.FlagsCaptured.Text = team2Flags.Value
  58.             end
  59.         end)
  60.        
  61.         teamsFrame.Visible = true  
  62.        
  63.         child.Destroying:Connect(function()
  64.             teamsFrame.Visible = false
  65.         end)
  66.     end
  67. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement