Player queue scripting help

Hi’ I’m trying to make a queue sysem, that has stop points, like 10. And when a player touches a part, it :moveTo() the player to the farthest avalible waiting point. When the player’s character arrives, it marks as occupied. If the door is opened, players can exit the queue, but if its not, they just stand there.

I can’t give example, but I want to get this.

If someone has a model or a done script help would be appreciated.

What script do you currently have for this?

I haven’t started it.

Update! I got example. Watch Roblox 2024-08-23 18-23-17 | Streamable

So you’re more or less asking someone to make it for you?

Basicly more. I’m not the best scripter in the universe.

Then I’d suggest commissioning someone to make this for you unless someone is willing to do it for free.

Can’t you give me some starting points to where to start from? I have no idea.

  1. Please put this in the correct category.
  2. I do not understand what exactly your post is asking for.

alrighty so first make waiting point parts in your game, name them WaitingPoint1, WaitingPoint2, etc
group these parts under a model or folder named WaitingPoints - if you’re using StreamingEnabled in the game, just so the parts don’t get streamed out, i recommend you use a model and set the model’s streaming mode to Persistent
now put a script in the part that you want the player to touch to enter
replace the script’s default code with this:

local waitingPoints = workspace.WaitingPoints:GetChildren()
local occupiedPoints = {}

--finds the farthest available waiting point
local function getFarthestAvailablePoint()
    for i = #waitingPoints, 1, -1 do
        if not occupiedPoints[i] then
            return waitingPoints[i], i
        end
    end
    return nil
end

local function onTouch(part)
    local character = part.Parent
    local humanoid = character:FindFirstChild("Humanoid")
    
    if humanoid then
        local player = game.Players:GetPlayerFromCharacter(character)
        local waitingPoint, index = getFarthestAvailablePoint()
        
        if waitingPoint then
            character:SetPrimaryPartCFrame(waitingPoint.CFrame)
            occupiedPoints[index] = player
            
            --(assuming you have a door script)
            local door = workspace:FindFirstChild("Door")
            if door and door:IsA("Model") then
                local doorOpen = door:GetAttribute("Open") --(if there's an attribute to check door state)
                if doorOpen then
                    table.remove(occupiedPoints, index)
                    -- now u handle exit logic here
                end
            end
        else
            player:Kick("No available waiting points in the queue.")
        end
    end
end

script.Parent.Touched:Connect(onTouch)

now for the door logic (under door part or wtv):

local door = script.Parent

function openDoor()
    door:SetAttribute("Open", true)
    -- over here code however you wanna open the door, e.g. tweening position, etc
end

function closeDoor()
    door:SetAttribute("Open", false)
    -- over here code however you wanna close the door, e.g. tweening position, etc
end

-- so u need to use functions openDoor() and closeDoor() to control the door as needed

yeah uhhh itll be smth like this
now u need to edit the main queue script to allow players to exit when the door opens - u can do this by removing the player from the occupiedPoints table and taking them to an exit point

by what i gave, when completed, players should be moved to the farthest available waiting point, and they should stay there until the door opens
anyways cya and lmk if u need anything thing else or have questions etc

MARK SOLUTION AAAAAAAAAAAAAAAAAAAAAAAAAAA

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.