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

Why does this loop keep crashing my studio?

Asked by
neoG457 315 Moderation Voter
8 years ago
CarbonH.Touched:connect(function(part)

local debounce = false
local h = part.Parent:FindFirstChild("Humanoid")
    if not h and (not debounce) and (part.Parent ~= Player.Character) and (part.Parent.Parent ~= Player.Character) then

        debounce = true

        local function debri()

local   Debri = Instance.new("Part")
        Debri.BrickColor = part.BrickColor
        Debri.Material = part.Material
        Debri.Anchored = true
        Debri.CanCollide = true 
        Debri.Size = Vector3.new(math.random(5, 20), 4, math.random(5, 20))
        Debri.CFrame = CFrame.new(CarbonH.Position) * CFrame.Angles((math.random()-0.5)*math.pi*2.4, (math.random()-0.5)*math.pi*2.4, (math.random()-0.5)*math.pi*2.4)
        Debri.Parent = workspace    
        Debri.TopSurface = 10
        Debri.BottomSurface = 10    

local   Debri2 = Instance.new("Part")

        Debri2.BrickColor = BrickColor.new("Black")
        Debri2.Material = 800
        Debri2.Anchored = false
        Debri2.CanCollide = true    
        Debri2.Size = Vector3.new(5, 5, 5)
        Debri2.CFrame = CFrame.new(CarbonH.Position) 
        Debri2.Parent = workspace   
        Debri2.TopSurface = 10
        Debri2.BottomSurface = 10


        for i = 1, 4 do

        local   Debris = Debri:Clone()
                Debris.Parent = workspace
                Debris.Size = Vector3.new(math.random(5, 20), 4, math.random(5, 20))
                Debris.CFrame = CFrame.new(CarbonH.Position) * CFrame.Angles((math.random()-0.5) * math.pi * 2.4, (math.random()-0.5) * math.pi * 2.4, (math.random()-0.5) * math.pi * 2.4) 

            end
                end

                local ExplosionRingPart= Instance.new("Part")

                local ExplosionRingMesh = Instance.new("SpecialMesh", ExplosionRingPart)
                ExplosionRingPart.Anchored = true
                ExplosionRingPart.CanCollide = false
                ExplosionRingPart.Transparency = 0.5
                ExplosionRingPart.CFrame = CFrame.new(CarbonH.Position - Vector3.new(0, 2, 0)) * CFrame.Angles(1/2 * math.pi, 0, 0)
                ExplosionRingMesh.Scale = Vector3.new(5, 5, 0.3)
                ExplosionRingMesh.MeshId = "http://www.roblox.com/asset/?id=3270017"
                ExplosionRingPart.Parent = workspace

                while ExplosionRingMesh.Scale.X ~= 10 and ExplosionRingPart.Transparency ~= 1 do -- the loop that keeps crashing

                    ExplosionRingMesh.Scale = ExplosionRingMesh.Scale + Vector3.new(1, 1, 0)
                    ExplosionRingPart.Transparency = ExplosionRingPart.Transparency + 0.1

                    wait(0.1)

                end 

        debri()
        CarbonH:Destroy()


        end
            end)

I dont see any problems and the there are no errors in the output. I have no idea why it keeps crashing, please help. Sorry if the code is hard to read, I tried my best to make it as simple as possible.

0
did you add a wait() in the first for loop? lucas4114 607 — 8y
0
Nope that didnt help ;-; neoG457 315 — 8y
0
You have an infinite loop somewhere, that means it will always function, meaning that Studio can't work. (Aka, try to remove it and see if it works) TheHospitalDev 1134 — 8y
0
It doesnt crash when I remove the while loop, however I can't see how the while loop is infinite. neoG457 315 — 8y
View all comments (4 more)
0
trying putting a wait() right after the while loop. Async_io 908 — 8y
0
Nope didnt work neoG457 315 — 8y
0
Try ExplosionRingMesh.Scale.X < 10 instead of ExplosionRingMesh.Scale.X ~= 10 PlsNoDiscrimination 0 — 8y
0
Still no neoG457 315 — 8y

Answer this question