Team only seat and popup gui on seated

So i want to make a team only seat so girls can’t seat on boys seat i wonder how can i do that?

2 Likes

You can use humanoid.seated to detect if a player is sitting on a seat.

From there you could find which team the player is on, either male or female, and force the player off the seat by setting humanoid.Sit to false if the team their on is female.

local player = game.Players.LocalPlayer
repeat wait() until player.Character  -- Wait until character has loaded
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local boys = game.Teams.Boys
local girl = game.Teams.Girls

function onSeated(isSeated)  -- Code runs when function is fired
	if isSeated then
		if player.Team == girl then	-- If player is on team girl
			print("Is a girl")
			humanoid.Sit = false	-- Kicks player off of seat
		end
	else							-- If not, the player must be on team boy
		print("Is a boy")
	end
end
humanoid.Seated:Connect(onSeated)  -- humanoid is sitting, fires function above

but i made 2 seats one for girl and one for boy this script only let the boy seats and not the girl

image

You wouldn’t need two seats, the function in my code fires whenever a player sits on any seat

but the code says if the player is on a girl team they can’t seat on any seat i want the girl to seat only on the seat name “girl”

Didn’t notice that, you can just add another if statement to find out what seat the player has just sat on.

local player = game.Players.LocalPlayer
repeat wait() until player.Character
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local boys = game.Teams.Boys
local girl = game.Teams.Girls

local girlSeat = workspace.LoveSeat.Girl
local boySeat = workspace.LoveSeat.Boy

function onSeated(isSeated, seat)  -- Code runs when function is fired ("seat" is the seat the player is sitting on)
	if isSeated then
		if player.Team == girl then	-- If player is on team girl
			if seat == boySeat then
				humanoid.Sit = false	-- Kicks player off of seat
			end
		end
	else							-- If not, the player must be on team boy
		if seat == girlSeat then            -- Since the player is male, if he sits on a girl seat then
			humanoid.Sit = false
		end
	end
end
humanoid.Seated:Connect(onSeated)  -- humanoid is sitting, fires function above

2 Likes