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

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

Asked by
bossaeed2 -50
6 years ago

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 

0
Try something with coroutines. helperobc 52 — 6y
0
eh i need help idk how bossaeed2 -50 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago
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()
Ad
Log in to vote
0
Answered by
Uzuntu 6
6 years ago

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 
0
Also I would create a table out of all of those textures, like the guy above me, just makes it more organized. Uzuntu 6 — 6y
0
ill be clicking on a GUI surface so this wont work bossaeed2 -50 — 6y
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. Uzuntu 6 — 6y

Answer this question