Hello everyone! I am the creator of Unhinged Rooms.
But there is one problem. IMMENSE LAG.
After around 3-10 minutes of playing the game, you will start to notice lag that makes the game hard.
This will force you to constantly rejoin.
What could cause this?
The client scripts of the game:
while game.Players.LocalPlayer.Character.Humanoid:HasTag("Died") and game.SoundService.AmbientReverb ~= "NoReverb" do
workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
for i = 1, 10 do
wait(0.01)
workspace.CurrentCamera.CFrame = CFrame.Angles(workspace.CurrentCamera.CFrame.Rotation.X + (math.random(-3, 3) / 30), workspace.CurrentCamera.CFrame.Rotation.Y + (math.random(-3, 3) / 30), workspace.CurrentCamera.CFrame.Rotation.Z + (math.random(-3, 3) / 30))
end
game.SoundService.AmbientReverb = "NoReverb"
workspace.Music.Playing = false
local Blur = Instance.new("BlurEffect")
if workspace.Complete.Playing == false then
game.StarterGui:SetCore("ChatBarDisabled", true)
end
Blur.Parent = game.Lighting
local ColorCorrector = Instance.new("ColorCorrectionEffect")
game.Lighting.Offset.Enabled = false
ColorCorrector.Parent = game.Lighting
ColorCorrector.Saturation = -1
ColorCorrector.Brightness = 0.3
ColorCorrector.Contrast = 1
Blur.Size = 10
game.Lighting["Editor View"].Enabled = true
game.Lighting.Atmosphere.Density = 0
for i = 1, 10 do
Blur.Size -= 0.5
end
wait(0.5)
if workspace.Complete.Playing == false then
workspace.DeathAmbient.Playing = true
end
break
end
game.ReplicatedStorage.DoorTrigger.OnClientEvent:Connect(function(door)
if door >= 1 then
workspace.Ambiance.Playing = true
workspace.Ambiance2.Playing = true
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)
game.StarterGui:SetCore("ResetButtonCallback", false)
game.StarterGui:SetCore("BadgesNotificationsActive", false)
end
if door == 1 then
game.StarterGui:SetCore("ChatMakeSystemMessage", {["Text"] = "The Game Has Started.", ["Color"] = Color3.fromRGB(255, 249, 216), ["Font"] = Enum.Font.Code})
wait(1)
game.StarterGui:SetCore("ChatMakeSystemMessage", {["Text"] = "[Radio]: Alrighty."})
wait(1)
game.StarterGui:SetCore("ChatMakeSystemMessage", {["Text"] = "[Radio]: Investigators,"})
wait(3)
game.StarterGui:SetCore("ChatMakeSystemMessage", {["Text"] = "[Radio]: We must investigate for what happened to:"})
wait(3)
game.StarterGui:SetCore("ChatMakeSystemMessage", {["Text"] = "[Radio]: Todd,"})
wait(1)
game.StarterGui:SetCore("ChatMakeSystemMessage", {["Text"] = "[Radio]: Jonathan,"})
wait(1)
game.StarterGui:SetCore("ChatMakeSystemMessage", {["Text"] = "[Radio]: Jimmy,"})
wait(1)
game.StarterGui:SetCore("ChatMakeSystemMessage", {["Text"] = "[Radio]: And Jacob."})
wait(3)
game.StarterGui:SetCore("ChatMakeSystemMessage", {["Text"] = "[Radio]: Got it investigators?"})
wait(6)
game.StarterGui:SetCore("ChatMakeSystemMessage", {["Text"] = "[Radio]: Alright."})
end
if door == 25 then
wait(1)
game.StarterGui:SetCore("ChatMakeSystemMessage", {["Text"] = "[Radio]: Augh... Your radio is cutting out."})
wait(1)
game.StarterGui:SetCore("ChatMakeSystemMessage", {["Text"] = "[Radio]: CAN YOU HEAR ME?!"})
wait(1)
game.StarterGui:SetCore("ChatMakeSystemMessage", {["Text"] = "Use visual and audio cues to depict when to hide.", ["Color"] = Color3.fromRGB(255, 249, 216), ["Font"] = Enum.Font.Code})
wait(3)
game.StarterGui:SetCore("ChatMakeSystemMessage", {["Text"] = "You can hide under tables, behind curtains, even under a catwalk bridge! just keep in mind,", ["Color"] = Color3.fromRGB(255, 249, 216), ["Font"] = Enum.Font.Code})
wait(4)
game.StarterGui:SetCore("ChatMakeSystemMessage", {["Text"] = "You may break some bones trying.", ["Color"] = Color3.fromRGB(255, 249, 216), ["Font"] = Enum.Font.Code})
end
if door == 50 then
game.StarterGui:SetCore("ChatMakeSystemMessage", {["Text"] = "[Radio]: I thought i just heard something."})
wait(3)
game.StarterGui:SetCore("ChatMakeSystemMessage", {["Text"] = "[Radio]: Probably just a rat though."})
wait(1)
game.StarterGui:SetCore("ChatMakeSystemMessage", {["Text"] = "[A/50]: :)", ["Color"] = Color3.fromRGB(255, 255, 255)})
wait(1)
game.StarterGui:SetCore("ChatMakeSystemMessage", {["Text"] = "If you see a face on the door, you should hide.", ["Color"] = Color3.fromRGB(255, 249, 216), ["Font"] = Enum.Font.Code})
end
if door == 75 then
game.StarterGui:SetCore("ChatMakeSystemMessage", {["Text"] = "[Radio]: QEAJ89esY%98-ew&*#_W$Uw"})
wait(3)
game.StarterGui:SetCore("ChatMakeSystemMessage", {["Text"] = "The power is out.", ["Color"] = Color3.fromRGB(255, 249, 216), ["Font"] = Enum.Font.Code})
end
if door == 100 then
game.StarterGui:SetCore("ChatMakeSystemMessage", {["Text"] = "The building will be harder to navigate. Be careful.", ["Color"] = Color3.fromRGB(255, 249, 216), ["Font"] = Enum.Font.Code})
end
if door == 150 then
game.StarterGui:SetCore("ChatMakeSystemMessage", {["Text"] = "AAAAAAAAAAA", ["Color"] = Color3.fromRGB(255, 0, 4)})
end
wait(1)
if door == 300 then
print(door .. " has been reached.")
game.StarterGui:SetCore("ChatMakeSystemMessage", {["Text"] = "You have finished the game.", ["Color"] = Color3.fromRGB(255, 249, 216), ["Font"] = Enum.Font.Code})
wait(1)
game.StarterGui:SetCore("ChatMakeSystemMessage", {["Text"] = "[Radio]: Alrighty,"})
wait(1)
game.StarterGui:SetCore("ChatMakeSystemMessage", {["Text"] = "[Radio]: I think we have enough evidence."})
wait(3)
game.StarterGui:SetCore("ChatMakeSystemMessage", {["Text"] = "[Radio]: Let us report it."})
wait(3)
game.StarterGui:SetCore("ChatMakeSystemMessage", {["Text"] = "[Radio]: Todd,"})
wait(1)
game.StarterGui:SetCore("ChatMakeSystemMessage", {["Text"] = "[Radio]: Jonathan,"})
wait(1)
game.StarterGui:SetCore("ChatMakeSystemMessage", {["Text"] = "[Radio]: Jimmy,"})
wait(1)
game.StarterGui:SetCore("ChatMakeSystemMessage", {["Text"] = "[Radio]: And Jacob,"})
wait(5)
workspace["A-60Imprint"]:Play()
game.StarterGui:SetCore("ChatMakeSystemMessage", {["Text"] = "[A/300 (AKA Radio)]: And you will die sooner or later :)", ["Color"] = Color3.fromRGB(255, 0, 0)})
wait(3)
workspace["A-60Kill"]:Play()
game.Lighting.LightsOut.Enabled = true
game.Players.LocalPlayer.PlayerGui.ScreenGui.WinFrame.Visible = true
game.Lighting.LightsOut.Enabled = false
end
end)
game.Players.LocalPlayer.Character.Humanoid.PlatformStand = true
script.Parent.Parent.Visible = true
script.Parent.Activated:Connect(function()
script.Parent.Parent:Destroy()
game.Players.LocalPlayer.Character.Humanoid.PlatformStand = false
if workspace.RoomValue.Value >= 290 then
wait(0.25)
game.Players.LocalPlayer.Character:FindFirstChildOfClass("Humanoid")
end
end)
local stamina = 100
local sprinting = false
while wait() do
if sprinting == true and stamina >= 1 then
stamina -= 2
end
if stamina <= 99 then
stamina += 0.5
end
if stamina >= 5 and sprinting then
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 32
else
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 12
end
script.Parent.Size = UDim2.new(stamina * 0.0095, 0, 0.5, 0)
game:GetService("UserInputService").InputBegan:Connect(function(InputEvent)
if InputEvent.KeyCode == Enum.KeyCode.LeftShift then
sprinting = true
end
end)
game:GetService("UserInputService").InputEnded:Connect(function(InputEvent)
if InputEvent.KeyCode == Enum.KeyCode.LeftShift then
sprinting = false
end
end)
end
script.Parent.Activated:Connect(function()
script.Parent.Parent:Destroy()
end)
while wait() do
local Numeral = 0
while game.Players.LocalPlayer.Character.Humanoid:HasTag("Hidden") do
script.Parent.Visible = true
script.Parent.Bottom.Transparency = 1 - (Numeral / 240)
wait(0.1)
Numeral += 1
if Numeral > 240 then
game.ReplicatedStorage.RevivePlayer:FireServer()
workspace.TakeDamage:Play()
wait(1.5)
script.Parent.Visible = false
wait(3)
end
end
script.Parent.Visible = false
end
while wait() do
if game.Players.LocalPlayer.Character:FindFirstChild("HumanoidRootPart") and game.Players.LocalPlayer.Character:FindFirstChild("HumanoidRootPart").Position.Y <= 30 then
game.Lighting.Jumpscare.Enabled = true
script.Parent.ImageLabel.Size = UDim2.new(0, 100, 0, 100)
script.Parent.Yell:Play()
script.Parent.Fade:Play()
game.ReplicatedStorage.BeginRevive:FireServer()
for i = 1, 10 do
game.Lighting.Jumpscare.TintColor = Color3.fromHSV(math.random(0, 400) / 400, 1, 1)
script.Parent.ImageLabel.ImageColor3 = Color3.fromHSV(math.random(0, 400) / 400, 1, 1)
script.Parent.ImageLabel.Position = UDim2.new(math.random(50, 450) / 500, 0, math.random(50, 450) / 500, 0)
script.Parent.ImageLabel.Rotation = math.random(-23, 23)
script.Parent.ImageLabel.Size = UDim2.new(0, script.Parent.ImageLabel.Size.X.Offset + 50, 0, script.Parent.ImageLabel.Size.X.Offset + 50)
wait(0.001)
end
game.Lighting.Jumpscare.Enabled = false
script.Parent.Visible = false
end
end
Please help me solve this issue.