Help me with debounce please

map.EndPart.Touched:Connect(function(hit)
			if hit.Parent:FindFirstChild("Humanoid") and canWin == true then
				canWin = false
				local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
				plr.leaderstats.Wins.Value = plr.leaderstats.Wins.Value +1
				plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value +20
				
				
			end
		end)

i wanna achieve like when me press that i got that wins and cash and also when other player touch they get also wins and cash but

it didnt work only 1 plr can get the wins and cash when other touch they cant get the wins and cash please i really need asap

I believe that it is because you set canWin to false, and it does not go back after. you will want to do something like this

local finished = {}
map.EndPart.Touched:Connect(function(hit)
			if hit.Parent:FindFirstChild("Humanoid") then
                local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
                if not finished[plr] then
                    finished[plr] = true
				    plr.leaderstats.Wins.Value = plr.leaderstats.Wins.Value +1
				    plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value +20
			    end

			end
		end)

i want when all player touch the brick they can get wins and cash one time

Hey sorry I accidently sent that early. I am going to edit it to help you. :sweat_smile:

1 Like