Need Help Scripting Pushing a Button and T.V "show" starts

Hey, it’s me again.
I’m not the best at scripting, so I need a little help for a project.

So basically, I’m trying to have a button in one room to start playing decals for information about the game (it’s a go-kart racing group, if this helps), and I don’t know how to go about doing this. I know that it needs a click detector, and a script. Once again, not a very good scripter, but trying to learn!
Any help is appreciated! Thanks for your help!

1 Like

If you mean simply transitioning between images, you could use some pseudocode like…

local images = {"image_link", "image_link"} --//As many image links as you want. This will be iterated through orderly. It might help to preload these
local decal = script.Parent.Some_Decal --//Path to the decal you want to use.
local timer = 2 --//Time each image is displayed for
while wait() do
    for i, v in pairs(images) do --//Iterate over each image
        decal.Texture = v


Do you put this script in the object you want the decals on?

While wait() do shouldn’t be used, that hurt performance: Avoiding wait() and why

1 Like

How would you improve that code though?

Use while true do instead. That should work, and nothing might change relations to delay and that stuff, it’s just more optimized

If there isn’t a yield in a while loop generally it’ll crash the game.

1 Like

I don’t think that will crash the game, what do you mean with that.

I don’t even think there has to be body of code within a while loop; it’ll always crash the game if there isn’t a yield. I’d assume this has something to do with it running more frames than what’s allowed in Roblox (total speculation and a guess)

I think, if I’m not mistaken, adding a print in a while loop takes the place of a wait() call, but that’s not confirmed.

If you try running this in Studio:

while true do end

I can almost 99% guarantee you your game will crash.

Yeah but you have wait(displaytime) later on in the loop so there was not need as it will not yeld or crash the studio.

I know. I was just saying if you run this-

while true do end

It’s gonna crash the game; which is what Conejin recommended I change. I’m not angry nor am I trying to call anybody out here, I just wanted to clean that up a bit.

You can use another kind of loops (repeat until, for I,v, etc.)

While wait() do will work, but hurts performance, and it’s a bad practice.

yes, using while true do can crash the server instantly because it loops every millisecond. a way you can prevent this is using wait() at the end of the loop
for example:

while true do
--lines of code in this loop

this prevents it from looping every millisecond and doesnt make the loop crash the server.
also always insert a wait() at the end of a while loop if your using while true. it can help you make infinte loops that play every time but not crash the server at the same time.

You should avoid wait() , I left a link of a thread talking about this, instead of having an empty wait(), use at least wait(0.1), I recommend wait(0.5)

@Conejin_Alt, located in studio settings, there is a setting that has a number. that number is used if a wait() is left empty. usally the setting in default state is lower then 0.1. 0.1, or 0.5, isnt really good to use, since sometimes it can take longer. if you say it your way, i feel like you dont trust waits. using waits can be usful, if you use them correctly. also if you think waits are not trustable, why dont you rethink about their use. you might think they are not good to use, but it is your opinion. you may prefer not using them, but others think they are useful and thus they use them.

Use waits is useful, i know, and i have used them. But they are a bad practice:

And try to take the time to read the thread i have linked before. So you can have an answer.

again, your opinion. if they are a bad practice, people dont use 'em. but alot of people use them anyway, even if they are bad practice.

Yes, it’s my opinion, why you are not respecting that? And it’s a bat habit, something that is true, not my personal opinion, the guy who made that thread that i have linked before even said that. But if you read the thread i left before, you will understand why i wouldn’t use it.

Those alot of people are new developers, people who doesn’t care about performance, and people who don’t read too much articles provided by developers. It doesn’t matter about how much people is using that. Same as people using:



I’m not trying to be mean to you, i’m just trying to help you. If you don’t want to read the thread, here i will leave a quote, but please, read the thread. While you try to answer me to defend your answers and seem to be doing the right thing, you are increasingly harming yourself and will not help you.

If you want, you can ask some questions and a bit of help to Kampfkarren of why this is a bad habit.