I created a raycast that makes a part and after .5 seconds i create another part with the same CFrame and size of the first one, but alot bigger. (it's a laser beam cannon im making)
However, the touched event is only working when the person who shot the laser walks through it, and not the other players.
local beamDamage = Instance.new("Part") beamDamage.Parent = workspace game:GetService('Debris'):AddItem(beamDamage, 20) beamDamage.Transparency = .25 beamDamage.Anchored = true beamDamage.CanCollide = false beamDamage.Material = 'Neon' beamDamage.CFrame = beam.CFrame beamDamage.Size = Vector3.new(5,5,distance+20) beamDamage.BrickColor = BrickColor.new("Really red") beamDamage.Touched:Connect(function(hit) print('touched') if hit.Parent then local humanoid = part.Parent:FindFirstChild('Humanoid') if humanoid then if canDamage == true then humanoid:TakeDamage(80) canDamage = false end end end end ) wait(3) canDamage = true
this is a local script, but FE is off.
You seem to be searching for the Humanoid
from part
's Parent, but part
has not been defined. You should be looking in hit
's Parent.
local beamDamage = Instance.new("Part") beamDamage.Parent = workspace game:GetService('Debris'):AddItem(beamDamage, 20) beamDamage.Transparency = .25 beamDamage.Anchored = true beamDamage.CanCollide = false beamDamage.Material = 'Neon' beamDamage.CFrame = beam.CFrame beamDamage.Size = Vector3.new(5,5,distance+20) beamDamage.BrickColor = BrickColor.new("Really red") local canDamge = true beamDamage.Touched:Connect(function(hit) if not canDamage then return end canDamage = false; local humanoid = hit.Parent:FindFirstChild('Humanoid') if humanoid then humanoid:TakeDamage(80) end wait(3) canDamage = true; end )