why isnt the laser killing me ``` -- Part to shoot lasers from
local laserPart = workspace.LaserPart
-- Laser properties
local laserColor = Color3.new(1, 0, 0)
local laserThickness = 0.1
local laserLength = 50
-- Cooldown between laser shots
local cooldown = 1
-- Damage amount
local damage = 10
-- Function to create and fire a laser (CORRECTED and TESTED)
local function fireLaser()
-- Create the laser beam (same as before)
local laserBeam = Instance.new("Part")
-- ... (Laser beam creation and positioning code - same as before)
-- Destroy the laser after a short time (same as before)
delay(0.2, function()
laserBeam:Destroy()
end)
-- Damage players hit by the laser (CORRECTED RAYCAST and DAMAGE)
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
raycastParams.FilterDescendantsInstances = {laserPart, laserBeam}
local raycastResult = workspace:Raycast(laserPart.Position, laserPart.CFrame.LookVector * laserLength, raycastParams)
if raycastResult then
local hitPart = raycastResult.Instance
local humanoid = hitPart.Parent:FindFirstChild("Humanoid")
if humanoid then
-- Apply damage directly to the Humanoid (FINALLY!)
humanoid:TakeDamage(damage) -- This is the correct way to apply damage
end
end
end
-- Automatic firing loop (always on)
local function autoFireLoop()
while true do
fireLaser()
wait(cooldown)
end
end
coroutine.wrap(autoFireLoop)() -- Start the auto-fire loop
print("Laser script initialized. Laser firing automatically.")```