message.txt (4.4 KB)
So I have this script. When I run the place it’s fine, when I put ShopArea1 value to true the script works and it still goes fine, but when I put the value to false after putting it to true it crashes my laptop entirely after a few seconds as I put it to that. It just freezes my Roblox Studio and my laptop experiences very bad lag that at some point I can’t do anything and have to restart the laptop.
I tried reading the whole script and fixing some parts of it (the script I gave in this post counts these fixes), but it still crashes for me almost like as I said.
What I exactly need is to figure out why it crashes.
you should Send the script as a text and not a file
change all while true do loops to while true and task.wait() do
I tried but it doesn’t let me to submit as text.
here ill post it for him
local values = game.Workspace.MetroMap.Part1.Area2.Values
local sa1p = game.Workspace.MetroMap.Part1.Area2.TouchParts.ShopArea1Part
local light = script.Parent.SurfaceLight
local angle = light.Angle
local neon = script.Parent
local anglevalue = script.Parent.SurfaceLight.AngleNum.Value
local anglevalue2 = script.Parent.SurfaceLight.AngleNum2.Value
local mrnum1 = script.Parent.MRNum1.Value
local mrnum2 = script.Parent.MRNum2.Value
local malfunctcd = script.Parent.MalfunctCD.Value
local player = game:GetService("Players")
local function disable()
neon["Enabled?"].Value = false
neon.Material = Enum.Material.SmoothPlastic
light.Enabled = false
light.Angle = 0
neon.LampsSound1:Stop()
end
local function enable()
local function enable1()
neon.LampsSound2:Play()
neon.Material = Enum.Material.Neon
light.Enabled = true
light.Angle = anglevalue2
end
local function enable2()
neon["Enabled?"].Value = true
neon.LampsSound1:Play()
local function angletween()
local tw = game:GetService("TweenService")
local twi = TweenInfo.new(
2,
Enum.EasingStyle.Back
)
local angletw = tw:Create(light, twi, {Angle = anglevalue})
angletw:Play()
end
neon.Material = Enum.Material.Neon
light.Enabled = true
angletween()
end
local function rng1()
enable1()
wait(0.15)
disable()
wait(0.15)
end
local function rng2()
enable1()
wait(0.25)
disable()
wait(0.15)
end
local function rng3()
enable1()
wait(0.5)
disable()
wait(0.15)
end
local function rngenable()
local mr1 = math.random(1,3)
if mr1 == 1 then rng1()
else if mr1 == 2 then rng2()
else if mr1 == 3 then rng3()
end
end
end
end
local function lightmalfunct()
local lmmr2 = math.random(1,7)
local lmmr1and2 = math.random(1,mrnum2)
local function lightmalfunction1()
local function lightmalfunct1()
neon.MalfunctSound1:Play()
disable()
wait(2)
rngenable()
rngenable()
enable2()
neon.MalfunctSound1:Stop()
end
local function lightmalfunct2()
disable()
wait(10)
neon.MalfunctSound3:Play()
rngenable()
enable2()
end
local function lightmalfunct3()
disable()
rngenable()
enable2()
end
local function lightmalfunct4()
script.Parent.Parent.Cube.Attachment.ParticleEmitter.Script.Disabled = false
neon:Destroy()
end
local function lightmalfunct5()
rngenable()
enable2()
neon.MalfunctSound2:Play()
wait(10)
neon.MalfunctSound2:Stop()
rngenable()
enable2()
end
local function lightmalfunct6()
script.Parent.Parent.Cube.Attachment.MalfunctSound3:Play()
neon.Color = {17,17,17}
disable()
neon.ParticleEmitter1.Rate = 0
script:Destroy()
end
local function lightmalfunct7()
neon.ParticleEmitter1.Rate = 1
light.Brightness = light.BrightNum2
wait(15)
light.Brightness = light.BrightNum1
neon.ParticleEmitter1.Rate = 0
end
if lmmr2 == 1 then
lightmalfunct1()
if lmmr2 == 2 then
lightmalfunct2()
if lmmr2 == 3 then
lightmalfunct3()
if lmmr2 == 4 then
lightmalfunct5()
if lmmr2 == 5 then
lightmalfunct7()
if lmmr2 == 6 then
if lmmr1and2 == 1 then
if math.random(1,2) == 1 then
lightmalfunct4()
else
lightmalfunct6()
end
end
end
end
end
end
end
end
end
local lmmr1 = math.random(1,mrnum1)
sa1p.Touched:Connect(function(hit)
if player:GetPlayerFromCharacter(hit.Parent) then
if lmmr1 == 1 then
lightmalfunction1()
wait(malfunctcd)
end
end
end)
end
rngenable()
rngenable()
rngenable()
enable2()
neon["Enabled?"].Changed:Connect(function()
if neon["Enabled?"].Value == true then
while true do
lightmalfunct()
if neon["Enabled?"].Value == false then
break
end
end
end
end)
end
values.A1Lamp1Power.ShopArea1.Changed:Connect(function(Value)
if Value or neon["Enabled?"].Value == true then
enable()
else
disable()
end
end)
you forgot to add a wait at line 302. You should replace it with
while wait() do
Or there might be a wait inside the lightmalfunct() function that im not seeing