#Plater UI only clones one at a time

3 messages · Page 1 of 1 (latest)

dry geyser
#

Hey So i want the UI to pop up whenever player goes to a register, but I tried with two players going to different registers. The UI only popped up to one player.

#
function Cashier:Init()
    coroutine.wrap(function()
    for i, v  in pairs(registerSpots) do
        if v:IsA("Part") then
            v.Touched:Connect(function(hit)
                if self.Cashier.CashierDebounce == false then
                    self.Cashier.CashierDebounce = true
                    local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
                    if player and self.Cashier.OccupyDebounce == false then
                        self.Cashier.OccupyDebounce = true
                        local humanoidRoot = hit.Parent:FindFirstChild("HumanoidRootPart")
                        self:Occupy(v.Name, humanoidRoot, player)
                    end
                    self.Cashier.CashierDebounce = false
                    end
                end)
            end
        end
    end)()
end
#
function Cashier:Occupy(object, instance, player)
    if workspace.Register.Spots:WaitForChild(object).Taken.Value == "false" then
        if self.Cashier.uiDebounceCashier == false then
            self.Cashier.uiDebounceCashier = true
            if self.Cashier.Registered == false then
                
                local playerGui = game.Players:WaitForChild(player.Name):WaitForChild("PlayerGui")
                local confirmPrompt = playerGui:FindFirstChild("OccupationConfirm"..player.Name)
                
                if not confirmPrompt then
                    confirmPrompt = script.OccupationConfirm:Clone()
                    confirmPrompt.Name = "OccupationConfirm"..player.Name
                    print('cloned for'..player.Name)
                    confirmPrompt.Parent = playerGui
                end
                
                local firstConnection 
                local secondConnection
                
                  firstConnection=replicatedStorage.ServerComponent.Cashier.Occupy.OnServerEvent:Connect(function(Player)
                    instance.CFrame = workspace.Register.Spots:WaitForChild(object).icon.CFrame
                    task.wait(0.1)
                    workspace:FindFirstChild(Player.Name).HumanoidRootPart.Anchored = true
                    workspace.Register.Spots:WaitForChild(object).Taken.Value = "true"
                    self.Cashier.Registered = true
                    workspace.Register.Spots:WaitForChild(object).icon.BillboardGui.Enabled = false
                    npcEnterance(object)
                    firstConnection:Disconnect()
                end)