Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer
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.

2 comments

0

thanks

0

np

This discussion is preserved as it was. New answers, comments, and votes are closed.