Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why are the lights crashing my game? [Answered]

Maybe it wasn't fixed...

My studio keeps crashing once I change the temp of the core in my computer core which changes the "ToggleEmergancyLights" value to false (because it is auto set to true anyway for testing purpose). Once that value changes. Studio crashes!

Please help me!

Tempreture script [Located inside the tempreture value in workspace]:

while true do
	if script.Parent.Value >= 1000 then
		game.Workspace.ToggleEmergancyLights.Value = true
		wait(0.1)
	else
		game.Workspace.ToggleEmergancyLights.Value = false
		wait(0.1)
	end
	wait(0.1)
end

WallLight script [Located in the walllight's pointlight]:

sp = script.Parent

bulb=sp.Parent
light=sp
bulb1=sp.Parent.Parent:WaitForChild("Light1")
bulb2=sp.Parent.Parent:WaitForChild("Light2")
toggle=game.Workspace:WaitForChild("ToggleEmergancyLights")


function update()
	--bulb.BrickColor=(toggle.Value and BrickColor.new("Really red")) or BrickColor.new("Pastel yellow")
	--bulb1.BrickColor=(toggle.Value and BrickColor.new("Really red")) or BrickColor.new("Pastel yellow")
	--bulb2.BrickColor=(toggle.Value and BrickColor.new("Really red")) or BrickColor.new("Pastel yellow")
	--light.Color=(toggle.Value and Color3.new(255/255,0/255,0/255)) or Color3.new(255/255,255/255,255/255)
	if toggle.Value == true then
		bulb.BrickColor = BrickColor.new("Really red")
		bulb1.BrickColor = BrickColor.new("Really red")
		bulb2.BrickColor = BrickColor.new("Really red")
		light.Color = Color3.new(255/255,0/255,0/255)
	else
		bulb.BrickColor = BrickColor.new("Pastel yellow")
		bulb1.BrickColor = BrickColor.new("Pastel yellow")
		bulb2.BrickColor = BrickColor.new("Pastel yellow")
		light.Color = Color3.new(255/255,255/255,255/255)
	end
end

toggle.Changed:connect(update)
update()

EmergancyLight script [Located in the spinning emergency light]:

--Stickmasterluke


sp=script.Parent


bulb=sp:WaitForChild("Bulb")
part1=sp:WaitForChild("Part1")
light1=part1:WaitForChild("SpotLight")
part2=sp:WaitForChild("Part2")
light2=part2:WaitForChild("SpotLight")
toggle=game.Workspace:WaitForChild("ToggleEmergancyLights")


function updatetoggle()
	--bulb.BrickColor=(toggle.Value and BrickColor.new("Really red")) or BrickColor.new("Mid gray")
	--light1.Enabled=toggle.Value
	--light2.Enabled=toggle.Value
	if toggle.Value == true then
		bulb.BrickColor = BrickColor.new("Really red")
		light1.Enabled = true
		light2.Enabled = true
	else
		bulb.BrickColor = BrickColor.new("Pastel yellow")
		light1.Enabled = true
		light2.Enabled = true
	end
end


toggle.Changed:connect(updatetoggle)
updatetoggle()





rate=1/30
rps=1
currentrotation=math.random()

while true do
	wait(0.1)
	if toggle.Value == true then
		wait(rate)
		currentrotation=currentrotation+(rps*rate)
		part1.CFrame=((bulb.CFrame*CFrame.Angles(0,math.pi*2*currentrotation,0))*CFrame.Angles(0,0,math.pi*.5))*CFrame.new(0,0,part1.Size.z*.5)
		part2.CFrame=((bulb.CFrame*CFrame.Angles(0,math.pi*2*(currentrotation+.5),0))*CFrame.Angles(0,0,math.pi*.5))*CFrame.new(0,0,part2.Size.z*.5)
	else
	-- Do Nothing :P
	end
end

(Edited stickmasterluke's script)

1 answer

✓ Accepted answer

You need to add a wait() on every last line of a while true do loop otherwise Studio will crash no matter what

3 comments

0

I also realised it was the core :P

0

I c. Good luck with your project.

0

Thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.