Hello! I have an error on my script
So basicly what it does its that it gets all lasers of the folder and makes a touched funtion for each laser, but the debounce for each player marks an error and i dont know why, its wierd beacuse all works just fine but on the output it marks that table index is nil
Does anyone one how to dont get the error or why is it happening
Any help is apreciated
Error is on line 15
Script:
local debounces = { }
local Players = game:GetService("Players")
local AllLaser = script.Parent:GetChildren()
for _, Laser in pairs(AllLaser) do
if Laser:IsA("BasePart") then
Laser.Touched:Connect(function(hit)
local Player = Players:GetPlayerFromCharacter(hit.Parent)
if debounces[Player] then
return
end
debounces[Player] = true
Player.Character.Humanoid.Health = Player.Character.Humanoid.Health - 25
wait(0.5)
debounces[Player] = nil
end)
end
end