Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

My game having major lag on the server side?

Asked by 2 days ago
Edited 2 days ago

Hi, my game has a lot of lag when i'm around 5-10 minutes in the game. It only happens on the server side and not the client. Could anyone help me?

Game link if you need to try the lag: https://web.roblox.com/games/3178452919

I will appreciate it very much if i could get some help!

First script i suspect:

db = true
script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") and db == true then
        if hit.Parent.IsInARobbery.Value == true then
            db = false
            local player = game.Players:GetPlayerFromCharacter(hit.Parent)

            player.CameraMode = "Classic" 
            player.PlayerGui.RobberyCashGui.Frame.Visible = false
            player.PlayerGui.RobberyCompleteGui.Frame.Visible = true
            player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 
                        hit.Parent.RobberyCash.Value
            script.Parent.CarSound:Play()
            local escapemusic = 
                        player.PlayerGui.RobberyMusic.UraniumCompleted:Clone()
            escapemusic.Parent = player.PlayerGui
            escapemusic:Play()
            player.PlayerGui.Uranium:Remove()

            player.Character.Time.RobberyTime.Disabled = true
            player.Character.HumanoidRootPart.Anchored = true
            hit.Parent.Humanoid:UnequipTools()
            player.Backpack:ClearAllChildren()
            wait(0.1)
            db = true

        else
            if hit.Parent.IsInARobbery.Value == false and hit.Parent.TriedEscaping.Value 
                        == false then
                local player = game.Players:GetPlayerFromCharacter(hit.Parent)
                player.PlayerGui.EscapeFailedGui.TextLabel.Visible = true
                hit.Parent.TriedEscaping.Value = true
                wait(2.5)
                player.PlayerGui.EscapeFailedGui.TextLabel.Visible = false
                hit.Parent.TriedEscaping.Value = false
                db = true
            end
        end
    end
end)

Second script i suspect:

db = true
script.Parent.Touched:Connect(function(hit)
    if db == true then db = false
        script.Parent.Parent.Bomb1.Transparency = 0
        script.Parent.Parent.Bomb2.Transparency = 0
        script.Parent.Parent.Bomb3.Transparency = 0
        script.Parent.Parent.Bomb1.BrickColor = BrickColor.new("Bright red")
        script.Parent.Parent.Bomb2.BrickColor = BrickColor.new("Bright red")
        script.Parent.Parent.Bomb3.BrickColor = BrickColor.new("Bright red")
        script.Parent.Parent.Bomb1.Material = Enum.Material.Sand
        script.Parent.Parent.Bomb2.Material = Enum.Material.Sand
        script.Parent.Parent.Bomb3.Material = Enum.Material.Sand
        script.Parent.Parent.Parent.Union.BillboardGui.Enabled = true
        script.Parent.Parent.Parent.Union.BillboardGui2.Enabled = true
        wait(1)
        script.Parent.Parent.Parent.Union.BillboardGui.Time.Text = "4"
        script.Parent.Parent.Parent.Union.BillboardGui2.Time.Text = "4"
        wait(1)
        script.Parent.Parent.Parent.Union.BillboardGui.Time.Text = "3"
        script.Parent.Parent.Parent.Union.BillboardGui2.Time.Text = "3"
        wait(1)
        script.Parent.Parent.Parent.Union.BillboardGui.Time.Text = "2"
        script.Parent.Parent.Parent.Union.BillboardGui2.Time.Text = "2"
        wait(1)
        script.Parent.Parent.Parent.Union.BillboardGui.Time.Text = "1"
        script.Parent.Parent.Parent.Union.BillboardGui2.Time.Text = "1"
        wait(1)
        script.Parent.Parent.Parent.Union.BillboardGui.Time.Text = "0"
        script.Parent.Parent.Parent.Union.BillboardGui2.Time.Text = "0"
        wait(1)
            local e = Instance.new("Explosion")

            e.BlastRadius = 8

            e.BlastPressure = 100000

            e.Parent = game.Workspace

            e.Position = script.Parent.Parent.Parent.Union.Position
        script.Parent.Parent.Parent.Union.BillboardGui.Enabled = false
        script.Parent.Parent.Parent.Union.BillboardGui2.Enabled = false
        script.Parent.Parent.Parent.Union.BillboardGui.Time.Text = "5"
        script.Parent.Parent.Parent.Union.BillboardGui2.Time.Text = "5"
        script.Parent.Parent.Bomb1:Remove()
        script.Parent.Parent.Bomb2:Remove()
        script.Parent.Parent.Bomb3:Remove()
        wait(120)
        local serverstorage = game:GetService("ServerStorage")
        local newvaultdoor = serverstorage.VaultDoors.BankVaultdoor1:Clone()
        newvaultdoor.Name = "Vault door"
        newvaultdoor.Parent = script.Parent.Parent.Parent.Parent
        script.Parent.Parent.Parent:Remove()
    end
    end)
0
You need to elaborate! Please include ALL scripts that you suspect may cause lag. Did you use any loops breaking the game? What is the issue? Please, elaborate. I don't know what the issue is. 2Loos 108 — 2d
0
I don't see any lag in the game, but it is amazing! 2Loos 108 — 2d
0
are you using any while true do loops? And if so then do they have a wait() in them? Scryptol 2 — 2d
0
are you using any while true do loops? Scryptol 2 — 2d
View all comments (4 more)
0
If I show all scripts it will take me a while. I use a lot of while true do loops and I close them nicely with a wait. Bankrovers 11 — 2d
0
Using a lot of while loops is troublesome, even if you use a wait in each one (also it doesn't help at all if its just a wait() without a number). Try looking for other solutions for those things to work without while loops. zamd157 1153 — 2d
0
Oh yes, i got some scripts with a wait() . Without a number** Bankrovers 11 — 2d
0
wait() is okay it just waits until the last line of code is finished executing, making it the fastest method of waiting, but sometimes if you want two things to activate or do something at the same time, wait() can break them i guess. other than that i got no ideas AlexanderYar 92 — 1d

Answer this question