Wasn't exactly sure what to title this but here's my code:
local seatsFolder = game.Workspace.Plane.Body.Seats local function moveCharacter(plr) local counter = tostring(plr["valuesFolder"]["counterValue"].Value) if seatsFolder["Row"..counter].Seat1.SeatTaken.Value == false then print("no1 in seat 1") seatsFolder["Row"..counter].Seat1.SeatTaken.Value = true plr["valuesFolder"]["isSitting"].Value = true print(plr["valuesFolder"]["isSitting"].Value) seatsFolder["Row"..counter].Seat1.Seat:Sit(plr.Character.Humanoid) print("took seat1 of row"..counter) return true else if seatsFolder ["Row"..counter].Seat2.SeatTaken.Value == false then print("no1 in seat 2") seatsFolder["Row"..counter].Seat2.SeatTaken.Value = true plr["valuesFolder"]["isSitting"].Value = true print(plr["valuesFolder"]["isSitting"].Value) seatsFolder["Row"..counter].Seat2.Seat:Sit(plr.Character.Humanoid) print("took seat2 of row"..counter) return true else plr["valuesFolder"]["counterValue"].Value = plr["valuesFolder"]["counterValue"].Value + 1 print("row full.. checking next row of seats") end end end game.Players.PlayerAdded:Connect(function(player) local valuesF = Instance.new("Folder") valuesF.Parent = player valuesF.Name = "valuesFolder" local isSittingValue = Instance.new("BoolValue") isSittingValue.Parent = valuesF isSittingValue.Name = "isSitting" isSittingValue.Value = false local counterValue = Instance.new("NumberValue") counterValue.Parent = valuesF counterValue.Name = "counterValue" counterValue.Value = 1 repeat wait() until player.Character player.CameraMode = Enum.CameraMode.LockFirstPerson player.Character.Humanoid.JumpPower = 0 if db == false then db = true spawn(function() do repeat moveCharacter(player) until player["valuesFolder"]["isSitting"].Value == true end end) end end)
and essentially when a player joins they are put into the first seat available, every row has 2 seats and if both are taken it moves to the next row. there is a value inside of seats models (seatTaken) that I use to check if the seat is already taken and if it is, it moves on to the second seat in the row, and then finally the next row if both are taken. (haven't gotten to the part where the bool value (seatTaken) is put back to false when the player occupying the seat leaves.) I tested if this works by just putting the value to true and joining and it'd work just fine and move me to the next seat. got a friend to help me out and it'd try making me occupy the seat he was already in where the seattaken value was true but it'd still try making me sit in that seat. no clue whats wrong as the if statement continues even though seattaken is true. any ideas? (this is all in a server script inside serverscriptservice)
Instead of using bool values, you should use Seat.Occupant
value to check if is nil or not(or if the seat is taken or not, nil if is not taken).
Here is a little example of what I'm talking about:
local seat -- seat seat:GetPropertyChangedSignal('Occupant'):Connect(function() if seat.Occupant == nil then -- checks if there's no one sitting in "seat" print('nobody is sitting in my seat!') else -- if there is someone sitting there, then... print(seat.Occupant.Parent.Name.. ' is sitting in my seat!') -- prints Occupant model name(which is the player's username) end end)