I'm working on a round system, and I need the script to wait until the character has loaded until it continues but I don't know how. Anyone got a fix?
Here's the script:
local lobbylocation = workspace.Lobby.Lobby.Position + Vector3.new(0, 3, 0) local gamelocation = workspace.Maps.Main.Position + Vector3.new(0, 3, 0) local replicatedstorage = game:GetService("ReplicatedStorage") local timeevent = replicatedstorage:WaitForChild("TimeEvent") local propcount = replicatedstorage.PropCount local timeAmount = 20 game.Players.PlayerAdded:Connect(function(plr) plr.Team = game.Teams.Lobby replicatedstorage.ServerCount.Value += 1 end) game.Players.PlayerRemoving:Connect(function() replicatedstorage.ServerCount.Value -= 1 end) wait(1) local function playgame()--300 local timerText = "Time Left: " while timeAmount > 0 do timeevent:FireAllClients(timeAmount, timerText) wait(1) timeAmount -= 1 end end local function playintermission() local intermission = 10--60 local timerText = "Intermission: " while intermission > 0 do timeevent:FireAllClients(intermission, timerText) wait(1) intermission -= 1 end end local function resetplayers() for _, plr in pairs (game.Players:GetChildren()) do plr.Character.HumanoidRootPart.CFrame = CFrame.new(lobbylocation) end end local function teleportplayers() for _, plr in pairs (game.Players:GetChildren()) do local huntercount = replicatedstorage:WaitForChild("HunterCount") if huntercount.Value <= 0 then huntercount.Value += 1 plr.Character.PlayerTeam.Value = "Hunters" plr.Character.HumanoidRootPart.CFrame = CFrame.new(gamelocation) plr.Team = game.Teams.Hunters else propcount.Value += 1 plr.Character.PlayerTeam.Value = "Props" plr.Character.HumanoidRootPart.CFrame = CFrame.new(gamelocation) plr.Team = game.Teams.Props end end end local function resetall() for _, plr in pairs(game.Players:GetChildren()) do local huntercount = replicatedstorage:WaitForChild("HunterCount") huntercount.Value = 0 propcount.Value = 0 plr.Character.Humanoid.Health = 0 plr.Team = game.Teams.Lobby if plr.Team == game.Teams.Hunters then local propgun = plr:FindFirstChild("PropGun") or plr.Character:FindFirstChild("PropGun") if propgun then propgun:Destroy() end end end end local function hunterwait() for _, plr in pairs (game.Players:GetChildren()) do if plr.Team == game.Teams.Hunters then local hunterscreen = plr.PlayerGui:WaitForChild("HunterScreen") hunterscreen.Enabled = true wait(5) hunterscreen.Enabled = false local propgun = replicatedstorage:WaitForChild("PropGun") local gunclone = propgun:Clone() gunclone.Parent = plr.Backpack end end end while wait() do if replicatedstorage.ServerCount.Value >= 1 then resetplayers() playintermission() teleportplayers() hunterwait() if propcount.Value == 0 then print("HUNTERS WIN") resetall() end playgame() if propcount.Value == 0 then print("HUNTERS WIN") resetall() else if timeAmount == 0 then print("PROPS WIN") resetall() end end end end
If you want the character to fully load you should use the CharacterAppearenceLoaded event. This checks if the whole appearence of the character is loaded, meaning that the character is also fully loaded.
Here's an example
local function playerAdded(player) player.CharacterAppearanceLoaded:Connect(function(character) local hum = character:WaitForChild("Humanoid") if hum then print("The character is fully loaded") end end end Players.PlayerAdded:Connect(playerAdded)
Not that i havent tested it, but it should work
Hope this was helpful!
Any questions? Just ask!