Debounce for on touched event not working??
Not sure what's going on here but it could just be me being dumb, my debounce isn't working.
other than that everything is working fine
is it because of how I placed the debounce?
01 | game.Players.PlayerAdded:Connect( function (player) |
02 | script.Parent.Touched:Connect( function (hit) |
04 | local char = hit.Parent |
05 | local hum = char:FindFirstChild( "Humanoid" ) |
07 | local debounce = false |
09 | if hum and not debounce then |
12 | local players = game:GetService( "Players" ) |
13 | local player = players:GetPlayerFromCharacter(char) |
14 | local pack = player.Backpack |
15 | local findSword = pack:FindFirstChild(player.Name.. "'s sword" ) |
16 | local char = player.Character or player.CharacterAdded:Wait() |
17 | local equippedSword = char:FindFirstChild(player.Name.. "'s sword" ) |
18 | if not findSword and not equippedSword then |
21 | local SwordE = player:WaitForChild( "EquippedSword" ) |
23 | local Swordbank = game.ReplicatedStorage:WaitForChild( "SWORDBANK" ) |
24 | for _,Bank in pairs (Swordbank:GetChildren()) do |
25 | if Bank:IsA( "Tool" ) then |
26 | if Bank.Name = = SwordE.Value then |
29 | local CloneBank = Bank:Clone() |
30 | CloneBank.Name = (player.Name.. "'s sword" ) |
31 | CloneBank.Parent = char |