So, I'm trying to find the difference between the player who sent the FireServer request, and all other players in the server to check if they are within 300 studs, I tried this but I recieved the error bad argument expected string got table.
local repStorage = game:GetService("ReplicatedStorage") local remote = repStorage.Remotes:WaitForChild("senseRemote") remote.OnServerEvent:Connect(function(player) for i, v in pairs("game.Players:GetChildren()") do local inRange = (player.character.HumanoidRootPart.Position - v.Character.HumanoidRootPart.Position).magnitude if inRange < 300 and v.Team.Value ~= player.Team.Value then remote:Disconnect(player) end end end)
The "bad argument" error is because you're passing a string inside the pairs
method.
local repStorage = game:GetService("ReplicatedStorage") local remote = repStorage.Remotes:WaitForChild("senseRemote") remote.OnServerEvent:Connect(function(player) for i, v in pairs(game.Players:GetChildren()) do local inRange = (player.character.HumanoidRootPart.Position - v.Character.HumanoidRootPart.Position).magnitude if inRange < 300 and v.Team ~= player.Team then remote:Disconnect(player) end end end)
If you have any other concerns be sure to comment and we can figure it out :)