How do fix this GetChildren problem?

Hey there, I wrote a script where if the script did not find “CEO” in player then it would print “No CEO” but it did the opposite even when there is no such Children in the player(as shown on the right in Players)

Player = game:GetService("Players")


game.Players.PlayerAdded:Connect(function(player)
	local SV = Instance.new("StringValue")
	SV.Name = "Employee"
	SV.Parent = player
end)	

local ChosenCEO = Player.PlayerAdded:Connect(function(player)
	if player:GetChildren("CEO") then
		print("Found CEO")
	else
		print("No CEO")
	end	
	
		
end)

use FindFirstChild instead, which returns nil if it isn’t found

Player = game:GetService("Players")


game.Players.PlayerAdded:Connect(function(player)
	local SV = Instance.new("StringValue")
	SV.Name = "Employee"
	SV.Parent = player
end)	

local ChosenCEO = Player.PlayerAdded:Connect(function(player)
	if player:FindFirstChild("CEO") then
		print("Found CEO")
	else
		print("No CEO")
	end	
	
		
end)

AH OF COURSE! It completely slipped my mind. Thank so much man!

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