Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is this only changing one room to red when 2 players are checked in? What am I doing wrong?

Asked by
4D_X 118
6 years ago

So I'm making this hotel check-in system and I need it to check room availability. If there's 2 players in the game and they are both checked in, only one room shows to be checked in. LocalScript

    for i,v in pairs(workspace.CheckInNow.Rooms:GetChildren()) do
        local room = script.Room:Clone()
        room.Text = v.Name
        room.Parent = Main.RA.ScrollingFrame
        if Remote.Function.CheckRA:InvokeServer(v.Name) then
            room.BackgroundColor3 = Color3.fromRGB(255, 67, 70)
            room.BorderColor3 = Color3.fromRGB(255, 67, 70)
        elseif not Remote.Function.CheckRA:InvokeServer(v.Name) then
            room.BackgroundColor3 = Color3.fromRGB(85, 255, 127)
            room.BorderColor3 = Color3.fromRGB(85, 255, 127)
        end
        if v.Name == "Staff" then
            room.BackgroundColor3 = Color3.fromRGB(85, 85, 255)
            room.BorderColor3 = Color3.fromRGB(85, 85, 255)
        end
    end

Script

if workspace.CheckInNow.Rooms:FindFirstChild(room) then
    local a = 'non'
    for i,v in pairs(game.Players:GetPlayers()) do
        if v.Backpack:FindFirstChild(room) or v.Character:FindFirstChild(room) then
            print('room not taken '..room)
            a = true
        elseif not v.Backpack:FindFirstChild(room) and not v.Character:FindFirstChild(room) then
            print('room not taken'..room)
            a = false
        end
    end
    print(a)
    return a
end

No errors, no warnings, nothing.

Answer this question