I have a boss which teleports all the players nearest to it to a position but it only teleports the closest person once?
local tool = script.Parent
repeat task.wait() until script.Parent
local targetfound = false
repeat task.wait() until script.Parent.Name ~= "SansAttacks"
local mag = 4000
local player = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
--local TargetPosition = script.Function:InvokeClient(player,"MousePos") -- gets the mouse position
--================TargetPosition========================
local players = game.Players:GetChildren()
local range = 500
local lastmag= 1000
local mTorso = script.Parent.Parent:FindFirstChild("Torso")
local mHum = script.Parent:FindFirstChild("Humanoid")
for i=1,#players do
task.wait()
if players[i].Character then
local char = players[i].Character
if char:FindFirstChild("Torso") then
local Torso = char:FindFirstChild("Torso")
local mag = (Torso.Position - script.Parent.Torso.Position).magnitude
if mag<=range then
if char.Name ~= script.Parent.Parent then
if mag < lastmag then
mag = (Torso.Position - script.Parent.Torso.Position).magnitude
lastmag = mag
TargetPosition = Vector3.new(Torso.Position.x,Torso.Position.y,Torso.Position.z)
targetfound = true
if targetfound == true then
for i=1, #players do
wait()
if players[i].Character.HumanoidRootPart then
local hrp = players[i].Character.HumanoidRootPart
if hrp.Parent:FindFirstChild("HumanoidRootPart") then
hrp.Position = workspace.BlackBox.Base.Position
wait()
script.GasterBlasterRing.OwnersName.Value = script.Parent.Name
hrp.Position = workspace.BlackBox.Base.Position
players[i].Character.HumanoidRootpart.Position = workspace.BlackBox.Base.Position
local GToolModel = script["GasterBlasterRing"]:clone()
GToolModel.Parent = game.Workspace
task.wait(20)
hrp.Position = workspace.JudgementHall.PlayerPoint.Position
script:Destroy()
end
end
end
end
end
end
end
end
end
end -- end of for loop
--==========================
This is where I’m guessing the problem is
for i=1, #players do
wait()
if players[i].Character.HumanoidRootPart then
local hrp = players[i].Character.HumanoidRootPart
if hrp.Parent:FindFirstChild("HumanoidRootPart") then
hrp.Position = workspace.BlackBox.Base.Position
wait()
script.GasterBlasterRing.OwnersName.Value = script.Parent.Name
hrp.Position = workspace.BlackBox.Base.Position
players[i].Character.HumanoidRootpart.Position = workspace.BlackBox.Base.Position
local GToolModel = script["GasterBlasterRing"]:clone()
GToolModel.Parent = game.Workspace
task.wait(20)
hrp.Position = workspace.JudgementHall.PlayerPoint.Position
Help would be greatly appreciated thank you