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

Why do my functions stop after one play?

Achieve

I'm attempting to clean my script up and also have it stop when the Power value is false.

Issues

So, my issues are... 1) The functions don't stop when the Power is turned off. 2) The coding looks horrific and over-complicated. 3) The function only runs once and then stops.

Solutions

I originally had my end script, aka my error script like the following but it did only or three screens at a time and I need my all the functions to run at once. I tried using a coroutine.wrap, it made them all run extremely fast and they ended up timing out.

Note

Yes, I know all of the images connected in each function is the same. I did that on purpose to test each screen. They are all supposed to have different images when other people use them.

Issue part

script.Parent.Power.Changed:Connect(function(Power)
	if Power == true then
		repeat
			TVTop() --Activates the TVTop Function
			TV() --Activates the TV Function
			Screen1() --Activates the Screen1 Function
			Screen2() --Activates the Screen2 Function
			Side1() --Activates the Side1 Function
			Side2() --Activates the Side2 Function
			Side3() --Activates the Side3 Function
			Side4() --Activates the Side4 Function
		until not script.Parent.Power
	end
end)

Full Script

--[[Made By MillerrIAm]]--
-----------------------------------------------[INSTRUCTIONS!]-----------------------------------------------
--[[Hello! So the basic rundown of this is quite simple, you just need to fill out each asset as desired.
For all of the items below, you are able to change any functions below. 

Do not change the ID or the AssetLink, only change where it says ID Here.

If you'd like to add more screens for your new stages, you are able to but please be careful,
if you do not understand the coding below... you should get help before attempting to add more to this.

Any bugs you have with this system should be reported to MillerrIAm instantly. 
Any questions or concerns are able ot be answered by me.]]--
------------------------------------------------[Main Script]------------------------------------------------
local function TVTop() --OverheadTron
	local ID = game.Workspace.Equipment.Screens.TVTop
	local AssetLink = "http://www.roblox.com/asset/?id="
	ID.Image = AssetLink.."ID Here" 
	wait(0.5)
end

local function TV() --Jumbotron
	local ID = game.Workspace.Equipment.Screens.TV
	local AssetLink = "http://www.roblox.com/asset/?id="
	ID.Image = AssetLink.."ID Here" 
	wait(0.5)
end

local function Screen1() --Minitron Left
	local ID = game.Workspace.Equipment.Screens.Screen1
	local AssetLink = "http://www.roblox.com/asset/?id="
	ID.Image = AssetLink.."ID Here" 
	wait(0.5)
end
local function Screen2() --Minitron Right
	local ID = game.Workspace.Equipment.Screens.Screen2
	local AssetLink = "http://www.roblox.com/asset/?id="
	ID.Image = AssetLink.."ID Here" 
	wait(0.5)
end

local function Side1() --Floortron Left
	local ID = game.Workspace.Equipment.Screens.Side1
	local AssetLink = "http://www.roblox.com/asset/?id="
	ID.Image = AssetLink.."ID Here" 
	wait(0.5)
end

local function Side2() --Floortron Right
	local ID = game.Workspace.Equipment.Screens.Side2
	local AssetLink = "http://www.roblox.com/asset/?id="
	ID.Image = AssetLink.."ID Here" 
	wait(0.5)
end

local function Side3() --Sidetron Left
	local ID = game.Workspace.Equipment.Screens.Side3
	local AssetLink = "http://www.roblox.com/asset/?id="
	ID.Image = AssetLink.."ID Here" 
	wait(0.5)
end

local function Side4() --Sidetron Right
	local ID = game.Workspace.Equipment.Screens.Side4
	local AssetLink = "http://www.roblox.com/asset/?id="
	ID.Image = AssetLink.."ID Here" 
	wait(0.5)
end

------------------------------------------------[Power Function]------------------------------------------------
script.Parent.Power.Changed:Connect(function(Power)
	if Power == true then
		repeat
			TVTop() --Activates the TVTop Function
			TV() --Activates the TV Function
			Screen1() --Activates the Screen1 Function
			Screen2() --Activates the Screen2 Function
			Side1() --Activates the Side1 Function
			Side2() --Activates the Side2 Function
			Side3() --Activates the Side3 Function
			Side4() --Activates the Side4 Function
		until not script.Parent.Power
	end
end)

1 answer

Instead of doing

until not script.Parent.Power

You can do

until script.Parent.Power.Value == false

Hope that helped

2 comments

0

My issue is that 1) The functions don't stop when the Power is turned off. 2) The coding looks horrific and over-complicated. 3) The function only runs once and then stops.

0

Thank you for trying to help but this didn't help.

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