This is what I have currently, in the seat.

seat = script.Parent
teams = game:GetService("Teams")

seat.Changed:Connect(function()
	local occupant = seat.Occupant
	if occupant then
		local character = occupant.Parent
		local player = game.Players:GetPlayerFromCharacter(character)
		if player.TeamColor ~= ("New Yeller") then
			seat.Disabled = true
			seat.Disabled = false
		end
	else
		
	end
end)

However it gave me this error: Maximum event re-entrancy depth exceeded for Instance.Changed

And this error: While entering function defined in script 'Workspace.Kingseat.Seat.Script', line 4

Edit: I also tried this but it still does not work, however it outputs no error.

seat = script.Parent
teams = game:GetService("Teams")

seat.Touched:Connect(function()
	wait(0.1)
	local occupant = seat.Occupant
	if occupant then
		local character = occupant.Parent
		local player = game.Players:GetPlayerFromCharacter(character)
		if player.TeamColor ~= ("New Yeller") then
			seat.Disabled = true
			seat.Disabled = false
		end
	else
		
	end
end)

7 comments

0

TeamColor is not a string. It's a BrickColor. That means that the value you'll have to compare it to must be a BrickColor. Use the BrickColor.new() constructor.

0

That still did not help. It outputs no error and doesn't kick me off the seat when on the wrong team.

0

The seat must not have an occupant then.

0

Which code are you referring too, my first or my second?

0

Turns out I was just not waiting long enough for it to register if there was as occupant. Thanks for trying to help.

0

Nevermind it is still not working. It works but only after the first time I sit and then get off

0

BrickColor I believe can be converted to a string when you input it in tostring()