So i'm trying to make a bossfight attack where it shoots raycast lasers, as i'm also trying to make it delay the part where it actually deals damage, so that the player has a chance to actually avoid taking damage if they just keep moving.
Problem is, it doesn't do damage at all, unless you purposefully walk into the laser, mainly if you walk towards the direction it's coming from.
It doesn't even damage you if you stand still.
function LAZER()
local function RandomPlayer()
local players = game.Players:GetPlayers()
if #players > 0 then
return players[math.random(#players)]
end
end
for i = 1, 3 do
local Plr = RandomPlayer()
local Chr = Plr.Character
if Plr.Character and Chr:FindFirstChild("Torso") and Chr.Humanoid.Health > 0 then
wait(0.1)
local Lazor = Instance.new("Part", workspace)
Lazor.Anchored = true
Lazor.CanCollide = false
Lazor.Material = "Neon"
Lazor.BrickColor = BrickColor.new("Lavender")
Lazor.TopSurface = 0
Lazor.BottomSurface = 0
workspace.Sounds.Lazer:Play()
game:GetService("Debris"):AddItem(Lazor, 2)
local TorsoPos = Chr.Torso.Position
Lazor.Size = Vector3.new(1, 1, (workspace.Tizona.AttackPart1.Position - TorsoPos).magnitude)
Lazor.CFrame = CFrame.new(workspace.Tizona.AttackPart1.Position,TorsoPos)
Lazor.CFrame = Lazor.CFrame + Lazor.CFrame.lookVector*((workspace.Tizona.AttackPart1.Position - TorsoPos).magnitude/2)
wait(0.9) --Where I tried to make the delay
Lazor.touched:connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid then humanoid:TakeDamage(15)
if not humanoid then
end
end
end)
wait(.01)
end
end
end

2 comments
I don't see any raycasting in your script.
Well, I couldn't think of anything else to call it, honestly.