In the following code the “ApplyDescription” delays the code and makes it slower:
Code:
Full Code: local Module = {}
local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local LocalRemotes = ReplicatedStorage:WaitForChild("LocalRemotes")
local MAP = workspace:WaitForChild("Map")
local LDM = workspace:WaitForChild("LDM")
local SeekerSpawn = MAP:WaitForChild("SeekerSpawn").SpawnLocation
local MorphModule = require(ServerStorage.Assets.Morphs.MorphModule)
local Spawns = MAP.Spawns
local GameSettings = workspace.GameSettings
local Seconds = GameSettings.RoundTime.Seconds
local Decrease = Seconds.Parent.Decrease
local CharactersFolder = workspace.Characters
local EnemyUI = script.EnemyUI
local PlayerUI = script.InformationUI
local SeekersAmounts = {1, 1, 2, 2, 3}
local IntermissionTime = 40
local SelectingTime = 15
local MatchTime = 500
local SeekerAura = ServerStorage:WaitForChild("Assets"):WaitForChild("Character"):WaitForChild("Auras"):WaitForChild("Seekers")
local Seekers = {}
local FirstSeeker
local SecondSeeker
local ThirdSeeker
local function ApplyMorph(Character, Gender)
MorphModule:init()
MorphModule:applyModel(Character, Character, Gender, false)
end
local function RemoveMorph(Character)
MorphModule:removeModel(Character, Character)
end
local function SelectSeeker()
if GameSettings.GameStatus.Value ~= "" then
return
end
Seekers = {}
Seconds.Value = SelectingTime
Decrease.Value = true
GameSettings.GameStatus.Value = "Choosing"
local PlaceHolder = LDM.Props.Intro
local SeekersFolder = GameSettings:WaitForChild("Seekers")
local numPlayers = #CharactersFolder:GetChildren()
local SeekersAmount
if numPlayers >= 2 and numPlayers <= 4 then
SeekersAmount = 3
SelectingTime = 29+5
elseif numPlayers >= 5 and numPlayers <= 12 then
SeekersAmount = 2
SelectingTime = 21+5
elseif numPlayers >= 13 and numPlayers <= 20 then
SeekersAmount = 3
SelectingTime = 29+5
else
SeekersAmount = 1
SelectingTime = 10.5+5
end
local potentialSeekers = CharactersFolder:GetChildren()
local playerSeekers = {}
local dummySeekers = {}
for _, model in ipairs(potentialSeekers) do
if Players:GetPlayerFromCharacter(model) then
table.insert(playerSeekers, model)
else
table.insert(dummySeekers, model)
end
end
for i = 1, SeekersAmount do
local model
if i == 1 and #playerSeekers > 0 then
local index = math.random(1, #playerSeekers)
model = table.remove(playerSeekers, index)
else
local remainingSeekers = #playerSeekers > 0 and playerSeekers or dummySeekers
local index = math.random(1, #remainingSeekers)
model = table.remove(remainingSeekers, index)
end
model.Parent = SeekersFolder
table.insert(Seekers, model)
if i == 1 then
FirstSeeker = model
elseif i == 2 then
SecondSeeker = model
elseif i == 3 then
ThirdSeeker = model
end
print("SEEKER NUMBER: " .. i .. " - NAME " .. model.Name)
local dummy = PlaceHolder:FindFirstChild(tostring(i))
if dummy then
if Players:FindFirstChild(model.Name) then
local Player = Players:GetPlayerFromCharacter(model)
local humanoidDescription = Players:GetHumanoidDescriptionFromUserId(Player.UserId)
if dummy:FindFirstChild("Humanoid") then
dummy.Humanoid:ApplyDescription(humanoidDescription)
end
ApplyMorph(dummy, Player.Data.Gender.Value)
dummy.Torso:GetPropertyChangedSignal("Color"):Connect(function()
repeat task.wait() until dummy:FindFirstChild("M")
dummy:FindFirstChild("M").NewModel.Color = dummy.Torso.Color
end)
end
end
end
task.delay(5, function()
local SeekersFolder = GameSettings:WaitForChild("Seekers")
local numSeekers = #Seekers
for _, character in ipairs(Seekers) do
local player = Players:GetPlayerFromCharacter(character)
if player then
task.wait(1)
LocalRemotes.CharacterCamera:FireClient(player, numSeekers, table.unpack(Seekers))
end
end
end)
wait(SelectingTime)
Seconds.Value = 0
Decrease.Value = false
GameSettings.GameStatus.Value = "Prepare"
SeekerSpawn.Transparency = 0
SeekerSpawn.Information.Enabled = true
end
function Module.EndMatch(Winner)
GameSettings.GameStatus.Value = "Ended"
Winner = Winner or "NO ONE"
print("The WINNER IS:", Winner)
Seconds.Value = 0
for _, player in ipairs(Players:GetPlayers()) do
local character = player.Character
if character then
character.Humanoid.WalkSpeed = 0
character.Humanoid.JumpPower = 0
player.PlayerGui.UI.Gameplay.Main.Notification.Frame.Object.Text = Winner.." WON!"
player.PlayerGui.UI.Gameplay.Main.Notification.Start.Value = true
wait(4)
GameSettings.GameStatus.Value = ""
player.Character.Humanoid.Health = 0
wait(8)
player:LoadCharacter()
Seconds.Value = IntermissionTime
Decrease.Value = true
wait(IntermissionTime - 8)
game.ServerScriptService.GameManager.Enabled = false
wait(0.5)
game.ServerScriptService.GameManager.Enabled = true
end
end
end
local function SelectDay()
local TimesOfDay = {
{name = "Night", hour = 3},
{name = "Day", hour = 14},
}
local chosenTime = TimesOfDay[math.random(1, #TimesOfDay)]
if chosenTime.name == "Night" then
workspace.Settings.Sunny.Value = false
workspace.Settings.Rain.Value = true
else
workspace.Settings.Rain.Value = false
workspace.Settings.Sunny.Value = true
end
game.Lighting.ClockTime = chosenTime.hour
end
local function PreparePlayer(player)
SelectSeeker()
SelectDay()
repeat wait() until GameSettings.GameStatus.Value == "Prepare"
if player == nil then return end
Seconds.Value = IntermissionTime
Decrease.Value = true
if not GameSettings.Seekers:FindFirstChild(player.Name) then
local spawnIndex = math.random(1, #Spawns:GetChildren())
player.Character.Parent = GameSettings.Humans
player.Character.HumanoidRootPart.CFrame = Spawns:GetChildren()[spawnIndex].CFrame
PlayerUI:Clone().Parent = player.Character.Head
end
local function CloseMatch()
if Seconds.Value == 0 then
if GameSettings.GameStatus.Value == "Prepare" then
Seconds.Value = MatchTime
for _, seekerCharacter in ipairs(GameSettings.Seekers:GetChildren()) do
local seekerPlayer = Players:GetPlayerFromCharacter(seekerCharacter)
if seekerPlayer then
local toolName = seekerPlayer.Data.Equipped.Value
local tool = ServerStorage.Tools:FindFirstChild(toolName)
if tool then
tool:Clone().Parent = seekerPlayer.Backpack
end
end
seekerCharacter.HumanoidRootPart.CFrame = SeekerSpawn.CFrame * CFrame.new(-1, 0, 1)
EnemyUI:Clone().Parent = seekerCharacter.Head
if SeekerAura then
for _, particle in SeekerAura:GetChildren() do
particle:Clone().Parent = seekerCharacter.Torso
end
end
end
wait(1)
SeekerSpawn.Transparency = 1
SeekerSpawn.Information.Enabled = false
GameSettings.GameStatus.Value = "Active"
for _, player in ipairs(Players:GetPlayers()) do
player.PlayerGui.UI.Gameplay.Main.Counter.Visible = true
player.PlayerGui.UI.Gameplay.Main.PlayerFrame.Visible = true
TweenService:Create(player.PlayerGui.UI.Gameplay.Label, TweenInfo.new(0.65, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {TextTransparency = 0}):Play()
end
local ambience, music
if workspace.Settings.Rain.Value then
ambience = LDM.Sounds.Rain.Ambience
music = LDM.Sounds.Rain.Music
if workspace.Settings.Rain.Value then
ambience = LDM.Sounds.Rain.Ambience
music = LDM.Sounds.Rain.Music
elseif workspace.Settings.Sunny.Value then
ambience = LDM.Sounds.Sunny.Ambience
music = LDM.Sounds.Sunny.Music
end
if ambience and music then
ambience:Play()
music:Play()
TweenService:Create(ambience, TweenInfo.new(0.65, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {Volume = music.Volume + 0.1}):Play()
wait(1.5)
TweenService:Create(player.PlayerGui.UI.Gameplay.Label, TweenInfo.new(2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {TextTransparency = 1}):Play()
TweenService:Create(music, TweenInfo.new(0.65, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {Volume = 0.2}):Play()
end
elseif GameSettings.GameStatus.Value == "Active" then
Decrease.Value = false
LDM.Sounds.Rain.Ambience:Stop()
LDM.Sounds.Rain.Music:Stop()
LDM.Sounds.Sunny.Ambience:Stop()
LDM.Sounds.Sunny.Music:Stop()
LDM.Sounds.Rain.Ambience.Volume = 0
LDM.Sounds.Rain.Music.Volume = 0
LDM.Sounds.Sunny.Ambience.Volume = 0
LDM.Sounds.Sunny.Music.Volume = 0
workspace.Settings.Rain.Value = false
workspace.Settings.Sunny.Value = true
Module.EndMatch()
end
end
end
end
Seconds:GetPropertyChangedSignal("Value"):Connect(CloseMatch)
end
function Module.SpawnPlayer(player)
PreparePlayer(player)
end
return Module