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

How do I make a script that makes players teleport once 8 players touch a part?

Asked by 5 years ago
When 8 people are touching this scripts parent, which is player_teleporter
this script will start



local MainPrt = script.Parent

local TeleportID = 1 --ID OF MY PLACE


MainPrt.Touched:Connect(function(Prt)
for _,Plr in pairs(game.Players:GetPlayers()) do
if Plr.Character then
if Prt:IsDescendantOf(Plr.Character) then
game:GetService("TeleportService"):Teleport(TeleportID,Plr)
end
end
end
end)

here is the script i made so far. it doesnt work. i need help. pls tell me where my mistake is and how i fix it.

1 answer

Log in to vote
0
Answered by 5 years ago
local touchCount = 0
local touchers = {}
script.Parent.Touched:Connect(function(p)
    if p:IsA("BasePart") then
        touchCount = touchCount + 1
        table.insert(touchers,p.Parent.Name)
    end
end)
local TeleportID = 1
spawn(function()
    while true do wait()
        if touchCount >= 8 then
            for_, Plr in pairs(game.Players:GetChildren()) do
                game:GetService("TeleportService"):Teleport(TeleportID,Plr)
            end
        end
    end
end)

this is suppose to teleport the player once touchCount is greater than or equal to 8, i would recommend you add a TouchEnded, anyways, good luck... tell me if it works, click accept if it works.

0
thanks AwesomeMrBird -79 — 5y
0
np greatneil80 2647 — 5y
Ad

Answer this question