I’ve been trying to make a screen showing how many players are in each team and showing a frame when a certain value is reached: eg. If the value is 1 it shows the riot alert. BUT somehow it doesn’t show the alert when that value is reached. Please help.
local SDGetplayers = game.Teams["Security Department"]:GetPlayers()
local SDNumber = #SDGetplayers
local TTFGetplayers = game.Teams["Tactical Task Force"]:GetPlayers()
local TTFNumber = #TTFGetplayers
local TSGetplayers = game.Teams["Test Subjects"]:GetPlayers()
local TSNumber = #TSGetplayers
local RDGetplayers = game.Teams["Research Department"]:GetPlayers()
local RDNumber = #RDGetplayers
local FPGetplayers = game.Teams["Facility Personnel"]:GetPlayers()
local FPNumber = #FPGetplayers
local RaSDGetplayers = game.Teams["Repair and Service Department"]:GetPlayers()
local RaSDNumber = #RaSDGetplayers
while true do
script.Parent.TeamNumberSD.Text = SDNumber
script.Parent.TeamNumberTTF.Text = TTFNumber
script.Parent.TeamNumberTS.Text = TSNumber
script.Parent.TeamNumberRD.Text = RDNumber
script.Parent.TeamNumberFP.Text = FPNumber
script.Parent.TeamNumberRaSD.Text = RaSDNumber
if game.Workspace.Values.EventInProgress.Value == 1 then
script.Parent.RiotAlert.Visible = true
script.Parent.BreachAlert.Visible = false
script.Parent.WarheadAlert.Visible = false
script.Parent.RaidAlert.Visible = false
elseif game.Workspace.Values.EventInProgress == 2 then
script.Parent.RiotAlert.Visible = false
script.Parent.BreachAlert.Visible = true
script.Parent.WarheadAlert.Visible = false
script.Parent.RaidAlert.Visible = false
elseif game.Workspace.Values.EventInProgress == 3 then
script.Parent.RiotAlert.Visible = false
script.Parent.BreachAlert.Visible = false
script.Parent.WarheadAlert.Visible = true
script.Parent.RaidAlert.Visible = false
elseif game.Workspace.Values.EventInProgress == 4 then
script.Parent.RiotAlert.Visible = false
script.Parent.BreachAlert.Visible = false
script.Parent.WarheadAlert.Visible = false
script.Parent.RaidAlert.Visible = true
end
wait()
end
Hi,
I noticed the .Value is missing from the elseif statements, but the first one should still update.
I would check if any frames might be Transparent? or overlaying each other? (if they are meant to overlay, check the z-indexes)
Have you tested the other functions which change the EventInProgress values, to make sure they do actually change?
And do the team numbers update properly?
(Also task.wait() is preferred, no real difference, just a pointer)
-- Services
local Teams = game:GetService("Teams")
-- Teams
local TeamsTable = {
SDGetplayers = Teams["Security Department"],
TTFGetplayers = Teams["Tactical Task Force"],
TSGetplayers = Teams["Test Subjects"],
RDGetplayers = Teams["Research Department"],
FPGetplayers = Teams["Facility Personnel"],
RaSDGetplayers = Teams["Repair and Service Department"]
}
-- Values
local EventInProgress = workspace.Values:WaitForChild("EventInProgress")
-- Alerts
local Alerts = {
[1] = script.Parent.RiotAlert, -- [1] is event number
[2] = script.Parent.BreachAlert,
[3] = script.Parent.WarheadAlert,
[4] = script.Parent.RaidAlert
-- [5] = etc
}
-- Function
local function UpdateTeams()
if Alerts[EventInProgress.Value] then
local SDNumber = #TeamsTable.SDGetplayers:GetPlayers()
local TTFNumber = #TeamsTable.TTFGetplayers:GetPlayers()
local TSNumber = #TeamsTable.TSGetplayers:GetPlayers()
local RDNumber = #TeamsTable.RDGetplayers:GetPlayers()
local FPNumber = #TeamsTable.FPGetplayers:GetPlayers()
local RaSDNumber = #TeamsTable.RaSDGetplayers:GetPlayers()
script.Parent.TeamNumberSD.Text = SDNumber
script.Parent.TeamNumberTTF.Text = TTFNumber
script.Parent.TeamNumberTS.Text = TSNumber
script.Parent.TeamNumberRD.Text = RDNumber
script.Parent.TeamNumberFP.Text = FPNumber
script.Parent.TeamNumberRaSD.Text = RaSDNumber
for _, Alert in Alerts do
if Alert.Visible then
Alert.Visible = false
end
end
Alerts[EventInProgress.Value].Visible = true
end
end
-- Setup
UpdateTeams()
-- Events
for _, Team in TeamsTable do
Team.Changed:Connect(function()
UpdateTeams()
end)
end
EventInProgress.Changed:Connect(function()
UpdateTeams()
end)
Good script but um, I forgot to tell you that when there’s no event the value is 0 and it errors out because of that (the error is: Workspace.StatusScreen.Part.SurfaceGui.Script:48: attempt to index nil with ‘Visible’)
also, I had to fix the UpdateTeams function because it was getting the Teams service instead of the TeamsTable.