I’m unable to fully test this in game, as the game isn’t public, and studio server tests aren’t working for some reason, so can’t test if this even works
local PlayerInteractions = {}
local Players = game:GetService('Players')
local RunService = game:GetService('RunService')
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local function CheckDistance()
for _, player in pairs(Players:GetPlayers()) do
if player ~= Player then
local OtherCharacter = player.Character
if OtherCharacter then
if Player:DistanceFromCharacter(OtherCharacter.HumanoidRootPart) <= 10 then
print('You are near a player')
end
end
end
end
end
RunService.Stepped:Connect(CheckDistance)
return PlayerInteractions
StarterPlayer>StarterCharacterScripts>LocalScript>PlayerInteractions