I'm trying to create a script where all players apart from the user who casted it, freeze at the same time. However, at the moment; The script freezes people individually, then after they unfreeze, moves onto the next person and then the next etc. But I want everyone to freeze at the same time otherwise the color correction doesn't match up..
Any ideas?
My code:
game.ReplicatedStorage.Freeze.OnServerEvent:Connect(function(player) local TweenService = game:GetService("TweenService") local part = game.Lighting.ColorCorrection local Info = TweenInfo.new( 10, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, true, 0) local Goals ={ Saturation = -1} local tween = TweenService:Create(part,Info,Goals) tween:Play() for _, child in ipairs(game.Players:GetChildren()) do if child.Name ~= player.Name then local Them = child.Character wait() for _, NotThem in ipairs(Them:GetChildren()) do wait() if NotThem.ClassName == "Part" or NotThem.ClassName == "MeshPart" then NotThem.Anchored = true end end wait(20) for _, NotThem in ipairs(Them:GetChildren()) do wait() if NotThem.ClassName == "Part" or NotThem.ClassName == "MeshPart" then NotThem.Anchored = false game.Lighting.ColorCorrection.Saturation = 0 end end end end end)
Thank you.
Encapsulate the unfreeze in delay (it will create seperate threads for each player):
game.ReplicatedStorage.Freeze.OnServerEvent:Connect(function(player) local TweenService = game:GetService("TweenService") local part = game.Lighting.ColorCorrection local Info = TweenInfo.new( 10, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, true, 0) local Goals ={ Saturation = -1} local tween = TweenService:Create(part,Info,Goals) tween:Play() for _, child in ipairs(game.Players:GetChildren()) do if child.Name ~= player.Name then local Them = child.Character wait() for _, NotThem in ipairs(Them:GetChildren()) do wait() if NotThem.ClassName == "Part" or NotThem.ClassName == "MeshPart" then NotThem.Anchored = true end end delay(20,function() for _, NotThem in ipairs(Them:GetChildren()) do wait() if NotThem.ClassName == "Part" or NotThem.ClassName == "MeshPart" then NotThem.Anchored = false game.Lighting.ColorCorrection.Saturation = 0 end end end) end end end)