I want to, inside of a proximity.Triggered function, teleport all players that is inside of a part to another part. Could someone help me write that script or tell me how to do it?
COMMUNITY QUESTION
How do I teleport all players within an area or a part?
2 answers
game.ReplicatedStorage.TeleportEvent.OnServerEvent:Connect(function(plr,owner)
for _, plr in pairs(game.Players:GetChildren()) do
--add your position and offsets here
local ZOffset = math.random(-5,5)
local XOffset = math.random(-5,5)
plr.Character.HumanoidRootPart.CFrame = CFrame.new(owner.Character.HumanoidRootPart.Position.X + XOffset, owner.Character.HumanoidRootPart.Position.Y,owner.Character.HumanoidRootPart.Position.Z + ZOffset ) --Position can be changed here
end
end)
3 comments
0
this would teleport all players right?
0
But what I wanted is to teleport just the players that are inside of a specific part
0
use a region3 or Magnitude range check
hey you! have you ever heard of enes? if you are in trouble, better call enes!
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
Are you asking for help on the script or do you just want me to write the script for you?
I asked the question because I have no clue on where to begin. I have not done something like it before and therefore don't know how to write the script. Any help is appreciated!
This should be a smaller script I think because you would only change the CFrame of the players humanoidrootpart right? But I don't know how to get the players humanoidrootparts that are inside of this area or part.