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

How can i fix this simple thing about teleporting ? Please help me it`s fast ?

Asked by 3 years ago
local plrs = {}
local PlayersOn = game:GetService('ReplicatedStorage'):WaitForChild('PlayersOn')
local teleportService = game:GetService('TeleportService')
script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild('Humanoid') then
        local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
        if plr:FindFirstChild('Stats') then
            if plr.Stats.hasTouched.Value == false then
                plr.Stats.hasTouched.Value = true
                table.insert (plrs, plr)
            end
        end
        wait(0.2)
        PlayersOn.Value = #plrs
        if PlayersOn.Value == 1  and plr.Stats.hasTouched.Value == true then
            wait(13)
            teleportService:Teleport(6984250384, plr)

        end

    end
end)

-- 6984250384

Basically, i want to make when the players click a button like ''exit'' they get teleported outside this elevator and they don`t get teleported anymore, but i dont understand how to fix the script to do that, if i add a button1click inside the touch before the if playeron.value how can i remove that specific player from the table that click because i need a number to remove from the table, please help i give marked answer.

Answer this question