Im trying to make a kamehameha but when i use touch interest its laggy, region3 is glitchy and hits player when beam dont even hit them, and i dont know how to use magnitude so it gets the size of the beam. I also tried :gettouchingpart() but u have to have cancollide = true and players dont go in beam

Heres the code

start1 = script.Parent
end1 = script.Parent.Part
function castRay()
	
	
	local ray = Ray.new(
   start1.Position,                           -- origin
    (end1.Position - start1.Position).unit * (200) -- direction
	) 
	local ignore = game.Players.LocalPlayer.Character
	
	local hit, position = workspace:FindPartOnRay(ray, Player.Character, false, true)
	if hit then
	
	if hit.Parent:FindFirstChild("Humanoid") ~= nil then
		
		damage = Player.Data.Level.Value
			
		humanoid = hit.Parent:FindFirstChild("Humanoid")
		torso = hit.Parent:FindFirstChild("LowerTorso")
		humanoid.Health = humanoid.Health - damage*10
		body = Instance.new("BodyVelocity",torso)
		body.Velocity = root.CFrame.lookVector*10
game.Debris:AddItem(body,0.1)

	end
	end
end

3 comments

0

I'm pretty sure a ray in geometry cannot be bigger, so why would a ray in ROBLOX be bigger than just a infinite line?

0

just use an invisible part along the ray? rays are practically very small (if at all have any size / N/A) so maybe using a part would help?

0

But that wouldn't detect the first part detected from a object going from the player to the part