Currently trying to make a short loading system for 30 seconds and when all players load it stops. I detect that by a number value.
However, the number doesn’t go up so it just keeps counting down from 30.
CLIENT
-- Services: [CONTENDERS]
local Terrain = workspace:WaitForChild("Terrain")
local Players = game:GetService("Players")
local Lighting = game:GetService("Lighting")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
-- Services: [MISC]
local HapticService = game:GetService("HapticService")
local MarketplaceService = game:GetService("MarketplaceService")
local BadgeService = game:GetService("BadgeService")
local TeleportSerivce = game:GetService("TeleportService")
local MemoryStoreService = game:GetService("MemoryStoreService")
local DatastoreService = game:GetService("DataStoreService")
-- Folders: [MAIN]
local StoryElements = workspace:WaitForChild("StoryElements")
local InteractiveAssets = StoryElements:WaitForChild("InteractiveAssets")
local StoryCharacters = StoryElements:WaitForChild("StoryCharacters")
local StoryMusic = StoryElements:WaitForChild("StoryMusic")
local Functions_And_Events = ReplicatedStorage:WaitForChild("Functions_And_Events")
local Misc_Events = Functions_And_Events:WaitForChild("Misc_Events")
local Shake_Events = Functions_And_Events:WaitForChild("Shake_Events")
local Values_Folder = Functions_And_Events:WaitForChild("Values")
-- Remotes: [MAIN]
local CreateDialogue = Functions_And_Events:WaitForChild("CreateDialogue")
local ToggleGuiEvent = Functions_And_Events:WaitForChild("ToggleGuiEvent")
local TransitionEvent = Functions_And_Events:WaitForChild("TransitionEvent")
local SettingsEvent = Functions_And_Events:WaitForChild("SettingsEvent")
local SendErrorEvent = Misc_Events:WaitForChild("SendErrorEvent")
local LoadedEvent = Misc_Events:WaitForChild("LoadedEvent")
-- ACTUAL DETECTION CODE
if not game:IsLoaded() then
game.Loaded:Wait()
LoadedEvent:FireServer()
end
SERVER
LoadedEvent.OnServerEvent:Connect(function()
Values_Folder.PlayersLoaded.Value += 1
end)
for i = 30, 0, -1 do
CreateDialogue:FireAllClients("Players Loaded ("..Values_Folder.PlayersLoaded.Value.."/" ..#game.Players:GetPlayers()..")", "Please wait .. " ..i.." ", "None")
wait(1.1)
if #game.Players:GetPlayers() == Values_Folder.PlayersLoaded.Value then
-- Message(npc, "<i>All players loaded!</i>")
CreateDialogue:FireAllClients("Players Loaded ("..#game.Players:GetPlayers().."/" ..#game.Players:GetPlayers()..")", "<i>All players loaded!</i>", "None")
wait(2)
break
end
end
I don’t understand why the value isn’t going up upon the player loading. Can somone help?