Integrity Check Help

I’m trying to do an integrity check on a remote but it somehow always returns false even though the clientresponse is set to true

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remote = ReplicatedStorage.RemoteEvent

game.Players.PlayerAdded:Connect(function(player)
	while Players:FindFirstChild(player.Name) do
		local waitTime = 3
		local passedTime = 0

		local ClientResponded = false
		local Response
	
		repeat
			ClientResponded = false
			passedTime += 1
			task.wait(1)
			
			local a = Remote:FireClient(player)
			
			Remote.OnServerEvent:Connect(function(plr,a)
				if a then
					Response = a
					passedTime = 0
					ClientResponded = true
                    print(ClientResponded) -- True
				end
			end)
            print(ClientResponded) -- False somehow????????
		until passedTime > waitTime or ClientResponded == false

        print("Didn't respond")
	end
end)
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remote = ReplicatedStorage.RemoteEvent

game.Players.PlayerAdded:Connect(function(player)
    while Players:FindFirstChild(player.Name) do
        local waitTime = 3
        local passedTime = 0

        local ClientResponded = false
        local Response

        local connection -- Declare connection variable outside of repeat loop
        
        repeat
            passedTime += 1
            task.wait(1)
            
            -- Fire the RemoteEvent to the client
            Remote:FireClient(player)
            
            -- Connect the OnServerEvent callback to check for response
            connection = Remote.OnServerEvent:Connect(function(plr, response)
                if response then
                    Response = response
                    passedTime = 0
                    ClientResponded = true
                    print("ClientResponded:", ClientResponded) -- Should print true
                end
            end)
            
        until passedTime > waitTime or ClientResponded == false
        
        if not ClientResponded then
            print("Didn't respond")
        end
        
        if connection then
            connection:Disconnect() -- Disconnect the event connection
        end
    end
end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.