Two variables or three variables

How can I use two variables and determine which one is and which one is not,

local a = workspace:FindFirstChild('Spawn') or workspace:FindFirstChild('Spawn2')  or workspace:FindFirstChild('Spawn3')
if a == 'Spawn' then

or a == 'Spawn2' then

or a == 'Spawn3' then

end

Will it work? If there is no truth for the first variable?

There is a keyword called elseif which executes if the previous statement was false.

local a = workspace:FindFirstChild('Spawn') or workspace:FindFirstChild('Spawn2')  or workspace:FindFirstChild('Spawn3')
if a == 'Spawn' then

elseif a == 'Spawn2' then

elseif a == 'Spawn3' then

end
1 Like

You can just

local a = workspace:FindFirstChild('Spawn') or workspace:FindFirstChild('Spawn2')  or workspace:FindFirstChild('Spawn3')

if a then
	
end

But I also need to know the name of the given variable.

if a == 'Spawn2' then

end

Because he will be assigned other coordinates to move

local a = workspace:FindFirstChild('Spawn') or workspace:FindFirstChild('Spawn2')  or workspace:FindFirstChild('Spawn3')

if a then
	if a.Name == "Spawn" then
		
	elseif a.Name == "Spawn2" then
		
	elseif a.Name == "Spawn3" then
		
	end
end
1 Like

I just made a mistake when I wrote quickly, but thanks for your attention

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.