How would I make this door open only if the player touching it is from a certain team?

the script is:

DoorFront.Touched:Connect(function(hit)

	if debounce == false then
		debounce = true

		local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
		if player.TeamColor == "Lapis" then
				print("lapis")
	end

end)

I get this warning: Workspace.TestDoor.Script:13: attempt to index nil with ‘TeamColor’
(Also, please ignore how i’m missing a few ends because for some reason I can’t indent), in the actual script it’s there.

Try doing

if player.TeamColor == BrickColor.new('Lapis') then
    print('lapis')
end

So then your full script would be

DoorFront.Touched:Connect(function(hit)
	if debounce == false then
		debounce = true
		local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
		if player.TeamColor == BrickColor.new("Lapis") then
			print("lapis")
	    end
    end -- You were missing an end here
end)
1 Like

Change this to

if player.TeamColor == BrickColor.new("Lapis") then
1 Like

Yep, this worked! Thank you, however just wanted to point out it should have been two “=” signs instead of one.

Oh, yeah thanks for reminding me!