Second IF statment ain't working

I was trying to remake the owner title script thing for my friend’s game, it turned out to be working, everything gets printed… But when I put my ID inside the otherpeoplesids Table it completly breaks the script. It doesn’t clone the Other billboard gui to my character’s head nor printing anything.

local text = script:WaitForChild("Owner")
local textofthetitle = "OWNER"
local rainbowmode = true
local fontoftext = "Cartoon"
local colorofthetext = Color3.fromRGB(255, 255, 255)
local yourid = 1
local otherpeoplesids = {1795023834, 2}
local otherbguitext = "CO OWNER"
--start of the code:
game.Players.PlayerAdded:Connect(function(plr)
	if plr.UserId == yourid then
		print("step passed")
		plr.CharacterAdded:Connect(function(char)
			local headofthecharacter = char.Head
			print("step passed 2")
			local newtext = text:Clone()
			print("cloned")
			newtext.TextLabel.Text = textofthetitle
			newtext.Parent = char.Head
			newtext.TextLabel.Font = fontoftext
			if rainbowmode == true then
				newtext.TextLabel:WaitForChild("Script").Disabled = false
			elseif rainbowmode == false then
				--eao hax time
				print("rainbow mode is off.")
			end
		end)
		if table.find(otherpeoplesids, plr.UserId) then
			plr.CharacterAdded:Connect(function(char)
				print("yes")
				local text2 = script:WaitForChild("Other")
				local newtext = text2:Clone()
				print("cloned 2")
				newtext.TextLabel.Text = otherbguitext
				newtext.Parent = char.Head
				newtext.TextLabel.TextColor3 = colorofthetext
				newtext.TextLabel.Font = fontoftext
			end)
		end
		print("the end of the code ight.")
	end
end)

Any reply is appreciated as always!

1 Like

Try an elseif statement for that one.

2 Likes

Doesn’t work either, sadly. (30)

Which if statement is not working.

the second one inside the player added event.

For what do you need CharacterAdded event? Only to get players characters?

yes, the script is a serverscript, i cant use game.Players.LocalPlayer.Character

It worked now :+1: I just missspelled the script.

For server script you can use this to get player’s character:

game.Players.PlayerAdded:Connect(function(plr)
local char = plr.Character or plr.CharacterAdded:Wait()
-- The rest of the code
end)
1 Like

Thank you for your response, but it turned out that the bug is putting IF isntead of ELSEIF!