Luau doesn’t currently have a way to fire specifically to a table of clients. You will have to loop through the players within range and fire individually. I don’t know what needs your scripts have, but you could do this either in your attack system or pass the remote you want to fire to players in range into the mob function itself.
Firing inside the function:
local Players = game:GetService("Players")
local Mob = {}
Mob.__index = Mob
function Mob:RadiusEvent(remote)
for _, Player in Players:GetPlayers() do
local Character = Player.Character
if not Character then continue end
local Magnitude = (Character:GetPivot().Position - self.Instance:GetPivot().Position).Magnitude
local MaxDis = Mob.Config.FollowDistance
if Magnitude < MaxDis then
remote:FireClient(Player)
end
end
end
-- Inside the attack system somewhere
Mob:RadiusEvent(your_remote_event_here)
Firing from attack system somewhere:
local Players = game:GetService("Players")
local Mob = {}
Mob.__index = Mob
function Mob:GetPlayersInRadius(): {Player}
local PlayersInRange = {}
for _, Player in Players:GetPlayers() do
local Character = Player.Character
if not Character then continue end
local Magnitude = (Character:GetPivot().Position - self.Instance:GetPivot().Position).Magnitude
local MaxDis = Mob.Config.FollowDistance
if Magnitude < MaxDis then
table.insert(PlayersInRange, Player)
end
end
return PlayersInRange
end
-- Inside the attack system somewhere
local RadiusPlayers = Mob:GetPlayersInRadius()
for _,player in pairs(RadiusPlayers) do
RemoteEvent:FireClient(player)
end