I loop through the children of the player, and if a child is found, the remote event should NOT fire and it should continue to whatever code is after the loop and the initial if statement. How do I do this? My break statements are not working, my debug print does print correctly, but the remote event still fires. Here is the code:
if plr:WaitForChild("Paired").Value == "" then
for _, child in ipairs(plr:GetChildren()) do
if child.Name == "Walker" and child.Value == tostring(plrWT) then
print('this')
break
end
end
game.ReplicatedStorage.SendInfo:FireClient(plrWT, plr)
end
The remote event fires because it’s outside of the loop, all the “break” does it breaks out of the loop, to fix this put the remote event into an else
so it would look like this:
if plr:WaitForChild("Paired").Value == "" then
for _, child in ipairs(plr:GetChildren()) do
if child.Name == "Walker" and child.Value == tostring(plrWT) then
print('this')
break
else
game.ReplicatedStorage.SendInfo:FireClient(plrWT, plr)
end
end
end
sorry for the weird indentation, I wrote it in the DevForum not studio
This wouldn’t work as the if statement would iterate through for every child. For example, if the last item iterated through is not a string value, then it would break out before reaching it. I tried this as well.