I was looking around in the roblox dev forums and I saw this line of code that had a or in it, this is what I saw: ~~~~~~~~~~~~~~~~~ local Character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait() ~~~~~~~~~~~~~~~~~
I want to know how to use "or" in a variable
Or in a variable checks in order from left to right for a value that is not nil and not false and will use either the first one that is not nil and not false or the last one in the line.
local Character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
This script will first check if the player's character already exists in the workspace. If the character is nil (not spawned), then it will wait until the player's character is spawned.