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

Radius not always picking up people nearby?

Asked by 5 years ago

When there's two players in the server, one person can teleport fine with someone else, whilst the other can't do so?

For the other player, as they teleport to another player, the effects happen and they teleport but as they get to the player, the effects happen again and teleport that player to the same location by which the user just teleported to... Any ideas?

Server Script

game.ReplicatedStorage.Apparate.OnServerEvent:Connect(function(player, MouseHit)
local Debris = game:GetService("Debris")
local radius = 5
local children = game.Players:GetChildren()
for i, child in pairs(children) do

    if math.abs(child.Character.Head.Position.X - player.Character.Head.Position.X)<= radius or math.abs(child.Character.Head.Position.Z - player.Character.Head.Position.Z)<= radius then
    A = Instance.new("Fire")
    Debris:AddItem(A, 1)
    A.Heat = 10
    A.Size = 10
    A.Parent = player.Character.HumanoidRootPart
    B = Instance.new("Fire")
    Debris:AddItem(B, 1)
    B.Heat = 10
    B.Size = 10
    B.Parent = child.Character.HumanoidRootPart


    wait(.1)
       child.Character.HumanoidRootPart.CFrame = CFrame.new(MouseHit)
       player.Character.HumanoidRootPart.CFrame = CFrame.new(MouseHit)
wait(.5)
A:Remove()
B:Remove()
elseif  math.abs(child.Character.Head.Position.X - player.Character.Head.Position.X)>= radius or math.abs(child.Character.Head.Position.Z - player.Character.Head.Position.Z)>= radius then
    C = Instance.new("Fire")
    Debris:AddItem(C, 1)
    C.Heat = 10
    C.Size = 10
    C.Parent = player.Character.HumanoidRootPart

    wait(.1)
       player.Character.HumanoidRootPart.CFrame = CFrame.new(MouseHit)

wait(.5)
C:Remove()
    end

end
end)

Answer this question