Hello!
As you can see, i’m basically, checking if the Interaction name is ‘Police’ (interaction would be a part)
OtherInteractions is collection service tagged objects
For some reason when the name of ‘v’ is not “Police” still, doesn’t works or returns the ‘v’
I don’t think there’s an error?
The allowed teams is a Table with objects of the player tam, the ‘V’ name is ‘ClickDetection’
local function FindNearestOtherInteraction()
if player.Character then
if (not player.Character.Humanoid.Sit) and (player:WaitForChild('Interaction').Pinned.Value == false) and (player:WaitForChild('Interaction').Grabbing.Value == "") then
for i,v in ipairs(OtherInteractions) do
if player:DistanceFromCharacter(v.Position) <= 7 then
if v.Name == 'Police' then
if table.find(AllowedTeams, Player.Team) then
currentother = v
return v
end
end
if v.Name ~= 'Police' then
currentother = v
return v
end
end
end
end
end
lastother = nil
currentother = nil
return nil
end