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

Is it possible to add a stop and resume to this script ?

Is it possible to make this script pause the script when you click on an object and when you click again it runs ?

movie = script.Parent

while true do
wait(10)
movie.picy.Texture = "http://www.roblox.com/asset/?version=1&id=947990366"
wait(10)
movie.picy.Texture = "http://www.roblox.com/asset/?version=1&id=999441417"
wait(10)
movie.picy.Texture = "http://www.roblox.com/asset/?version=1&id=999062545"
wait(10)
movie.picy.Texture = "http://www.roblox.com/asset/?version=1&id=992753392"
wait(10)
movie.picy.Texture = "http://www.roblox.com/asset/?version=1&id=997539915"
wait(10)
movie.picy.Texture = "http://www.roblox.com/asset/?version=1&id=1079978330"
wait (0)
end 

2 comments

0

Try something with coroutines.

0

eh i need help idk how

2 answers

local images = {
	"947990366",
	"999441417",
	"999062545",
	"992753392",
	"997539915",
	"1079978330"
}

local stopped = false

local pic = movie:WaitForChild("picy")
local button = script.Parent:WaitForChild("ClickDetector")

local theLoop= coroutine.wrap(function()
	while true do
		for i = 1,#images do
			pic.Texture = "http://www.roblox.com/asset/?version=1&id="..images[i]
			wait(10)
		end
	end
end)

button.MouseClick:Connect(function(player)
	if stopped == false then
		stopped = true
		theLoop.yield()
	else
		stopped = false
		theLoop.resume()
	end
end)

theLoop()

What I did here was add a BoolValue and set it to true, and added an if then statement that checks the value of that BoolValue. As you can see, if the value is true, the script will break, which ends the loop. You can change it around as you want, but yeah, this might be what you want!

movie = script.Parent

value = Instance.new("BoolValue")
value.Parent = game.ReplicatedStorage
value.Name = "Test"
value.Value = true

while true do
wait()

if game.ReplicatedStorage.Test.Value == false then
	wait(10)
		movie.picy.Texture = "http://www.roblox.com/asset/?version=1&id=947990366"
	wait(10)
		movie.picy.Texture = "http://www.roblox.com/asset/?version=1&id=999441417"
	wait(10)
		movie.picy.Texture = "http://www.roblox.com/asset/?version=1&id=999062545"
	wait(10)
		movie.picy.Texture = "http://www.roblox.com/asset/?version=1&id=992753392"
	wait(10)
		movie.picy.Texture = "http://www.roblox.com/asset/?version=1&id=997539915"
	wait(10)
		movie.picy.Texture = "http://www.roblox.com/asset/?version=1&id=1079978330"
	wait (0)
else
break
end

end 

3 comments

0

Also I would create a table out of all of those textures, like the guy above me, just makes it more organized.

0

ill be clicking on a GUI surface so this wont work

0

Like I said, you can change it around easily. This is just an example to show you how it'll work. I can't do everything for you.

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