RBXScriptSignal

How does this work?

if RBXScriptSignal:Wait() then
    --code
end

(say RBXScriptSignal is part.Touched for example)

:Wait() makes the script yeild until the event occurs.

Putting it in the if statement is unusual, but I would assume it would prettymuch not change how it behaves.

RBXScriptSignal is a class that represents an event listener (a signal). Signals are a way to notify and communicate between different parts of a game. Oftentimes, they are used to create custom events that can be triggered and listened to by different scripts.

Whenever you say something like someEvent:Connect(someFunction), a signal is created that calls someFunction whenever someEvent is fired. When you call someSignal:Disconnect(), the signal is essentially destroyed and so the connected function (called a “callback”) is no longer run even if the event continues to be fired, unless you later create a new signal that calls the same function upon the firing of the same event.

The Wait function essentially stops the script and listens for the event to be fired and, once the signal is fired, allows the script to continue executing from the point where Wait was called. If you want to know more, check out the official documentation: