I have made a Mobile Data Terminal for my game for Law Enforcement Officers to use,
but I have ran into a problem when it came to checking if any of the players have a matching value.
Here’s how it works.
Once a player joins, the server generates a plate and stores it inside the player.
The officer inputs a Plate inside a Gui, and clicks a button, the Gui invokes the server and
it looks if any of the players has that same exact plate that the Officer input.
What’s the problem?
I’ve got everything working, thing is…
I have it set so if there is no plate detected, it shows an Error message,
well It does it for EVERY player that does not have a matching value, and that’s a problem
I want it to show the error once, if none of the players have a matching value.
I’ve tried debounce, and that didn’t work
Problematic Code
game.ReplicatedStorage.MDTEvents.LookupPlate.OnServerInvoke = function(Officer,Plate)
local Players = game.Players:GetChildren()
for i = 1, #Players do
if Players[i].Information.Plate.Value == Plate then
print('Found')
else
print('No players matching')
-- (This loops each time that it's not matching - I'd like it to do it ONCE if none are matching)
end
end
end