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!
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
wait(timer)
end
end
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.
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.
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
wait()
end
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 thinkwaits 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.
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:
_G.
.magnitude
:connect
Etc.
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.