Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is this so laggy?

Asked by 9 years ago

I have a script that's supposed to put a hole in a wall. I did that by making the hole-free wall already in workspace, and when you touch a certain part, it replaces the hole-free wall with the wall with a hole in it. When the wall explodes, I want there to be a couple pieces flying around so I added an explosion.

local w = workspace.BigBuilding.WallA
script.Parent.Touched:connect(function(part)
    local h = part.Parent:FindFirstChild("Humanoid")
    if h then
        wait()
        w:Destroy()
        local clone = game.ServerStorage.BWall:Clone()
        clone.Parent = workspace
        wait()
        local e = Instance.new("Explosion")
        e.Position = Vector3.new(239.48, 9.3, 74)
        e.BlastRadius = 25
        e.DestroyJointRadiusPercent = 0
    end
end)

I just want to know ways to make my scripts less laggy and more efficient.

Here is a gif, it shows you the hole, and what pieces i want to explode.

http://gyazo.com/7de2b8a653c1ef763f7d48ddd8db1444

Answer this question