So when I see code such as this

local rebirth = game.Workspace.Events.Rebirth
 if rebirth then
	rebirth:FireServer()
end

Why is the variable inside the if/then statement. Everytime I've tried to learn what this means, I always think that it means if it sees the variable anywhere it runs. It always runs though, no matter what. Can someone explain this to me?

1 comment

0

if will check to see if the provided condition is truthy - provided that rebirth is hooked to a valid object anywhere in your game, then it will be considered truthy. Your variable is essentially equal to true when called upon as a condition - purely because it exists.