Hi,
I'm trying to insert an if statement to play a sound with an elseif statement to not play the sound if ... happens. How do I insert a line to do nothing? I've tried:
if ... then script.Parent.Music:Play() else if ... then end
and
if ... then script.Parent.Music:Play() else if ... then script.Parent.Music:Stop() end end
however none of these worked. I'd greatly appreciate if someone could tell me how to do this. Thanks :)
That's uh, how if statements work. If the condition is true, the sound will play. So if it isn't true, nothing will happen. The sound won't play nor will it get launched into outer space and get sucked in by a black hole.
if ... then script.Parent.Music:Play() end
No need for a 'do nothing' line.
Hi, well, I see you're new to programming and don't yet fully understand the main syntaxes, let me explain the if conditions to you in a way that you don't need a hackerman.
If statements or just if points check if something exists, or if something has a specific value, it all depends on what you ask it to do.
What you might not understand in this context is how it is executed, if the condition or checks are not met, the if statement will not execute the code inside, and just carry on if there's more, for example:
local Cars = 6 local SkyColor = "blue" if Cars == 7 then print("There are 7 cars") end if SkyColor == "blue" then print("The sky is blue") end Expected output: > The sky is blue
im pretty sure you are going for something anti-exploitive, heres a good way to do such a thing
if not (...) then -- do stuff end