Im trying to get a elevator to start moving when 8 players are in the elevator how would i do this?
This is one way of doing it. Continuously checks the interior of the elevator using Region3
and FindPartsInRegion3
and checks the amount of players inside the elevator until 8 players are found. Be sure to modify min
and max
to replicate the actual size and coordinates of your elevator.
This also wasn't tested, so i'm not sure it works, but the algorithm should be correct. Let me know if you have any trouble.
local min = Vector3.new(0, 0, 0) local max = Vector3.new(10, 10, 10) local region = Region3.new(min, max) while true do local container = game.Workspace:FindPartsInRegion3(region, 100) local players = {} for _, child in pairs(container) do if (child.Parent:FindFirstChild("Humanoid")) then for _, element in pairs(players) do if (element.Name == child.Parent.Name) then break end end table.insert(players, child.Parent.Name) end end if (#players >= 8) then startGame() end wait(1) end
local touchCount = 8-- Amount of People local touchers = {" "} --Elevator Part Name 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 --Place ID 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)
Closed as Not Constructive by zblox164, namespace25, Lugical, and Goulstem
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?