Changing decal TV

`I’m trying to make a tv that every 5 seconds it will change the decal. Kind of like a fast food tv where it shows the menu and changes to show different part of the menu

Script while true do
script.Parent.Texture = “rbxassetid://7079865101”
wait(5)
script.Parent.Texture = “rbxassetid://7079865630”
wait(5)
script.Parent.Texture = “rbxassetid://7079879753”
wait(5)
script.Parent.Texture = “rbxassetid://7079888250”
wait(5)
script.Parent.Texture = “rbxassetid://7079901072”
wait(5)
end

This is how i set it up
https://gyazo.com/9cc6d39c9237a695c7c6cbb5d71b56ca

looked it up on YouTube didn’t find much.

1 Like

You’ve done the loop wrong, I believe. Try this:

while wait(5) do
script.Parent.Texture = "rbxassetid://7079865101"
end

Let me know if that works.

they are all different id’s

you need to use a table

1 Like

Ohh, I hadn’t noticed. Was @Robbie11111112 wanting it to choose a specific thing from a list every 5 seconds or a random item from a list every 5 seconds?

that part I am unsure about, maybe the first option?

while true do
while wait(5) do
script.Parent.Texture = “rbxassetid://7079865101”
while wait(5) do
script.Parent.Texture = “rbxassetid://7079865630”
while wait(5) do
script.Parent.Texture = “rbxassetid://7079888250”
while wait(5) do
script.Parent.Texture = “rbxassetid://7079901072”
end
end
end
end
end

i changed it to that and it still not working

Do you want it to select a random decal out of a table every time or the items in order?

in order because it a menu. it its out of order it won’t work like i want it

ok 1. that first loop has no yield
2. the first three id’s will run once and the fourth one will run every 5 seconds

obviously this won’t work

Okay, here. Try this:

tbl = {
    [1] = '7079865101',
    [2] = '7079865630',
    [3] = '7079888250',
    [4] = '7079901072'
}

while wait() do
    wait(5)
    script.Parent.Texture = tbl[1]
    wait(5)
    script.Parent.Texture = tbl[2]
    wait(5)
    script.Parent.Texture = tbl[3]
    wait(5)
    script.Parent.Texture = tbl[4]
local Table = {
    '7079865101',
    '7079865630',
    '7079888250',
    '7079901072'
}

while true do
    for i = 1, #Table, 1 do
        script.Parent.Texture = Table[i]
        wait(5)
    end
end

not sure why you didn’t use a for loop

Basically @D0RYU’s script but slightly cleaner. By the way D0RYU, you should put the wait right before the loop ends, or else when the game starts the TV will be blank for 5 seconds.

local Table = {
    '7079865101',
    '7079865630',
    '7079888250',
    '7079901072',
}

while true do
    for i,v in ipairs(Table) do
        script.Parent.Texture = v;wait(5)
    end
end

Recursion doesn’t add any benefits over a while loop, I don’t see why this would be necessary.

I edited my code, only thing I would improve on the edited code is remove the wait with a different yield method and add a parameter for the instance

May I see an example of this? If it’s a while true do loop, it shouldn’t stop.

while loops shouldn’t make new threads either, it’s all synchronous. If you put a print() after the while loop, it shouldn’t print anything until after the loop has concluded

I don’t see why this would be necessary either. Precision is only required for vital aspects of a game, not on background objects.

did you misread my post, sorry

what I meant by stop is this

while true do wait()

end

print("test")

it will never print test because the while loop is running
also I NEVER said while loops make a new thread

ur right it isn’t necessary, maybe the instance one if they are doing multiple instances but idk

none of them work this is whats happens.
https://gyazo.com/980badf308040f461378434610b9ab02

did you try @dukzae’s code yet?

yes i tried all three of them none work.

You implied this after comparing a while loop to recursion.

I haven’t tested this so I don’t have a real answer but I’m pretty sure that print() won’t be called.