Hello.
I’m currently having an issue with Raycasting.
Basically, I made a beam attack and made it so that the end of the beam is always at the ray’s collision with the other elements.
The problem is, the end of the beam keeps coming back and forward.
Script
The loop runs the code for about 2-3 seconds.
for count = 0, 200, 1 do
local rayOrigin = humanoidRootPart.Position
local rayGoal = GetCFramePosition(humanoidRootPart.CFrame + humanoidRootPart.CFrame.LookVector * 150)
local rayDirection = rayGoal - rayOrigin
local raycastResult = workspace:Raycast(rayOrigin, rayDirection)
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {character}
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
raycastParams.IgnoreWater = true
corruptedBeam:WaitForChild("Start").Position = rayOrigin
corruptedBeam:WaitForChild("Start").Orientation = humanoidRootPart.Orientation
corruptedBeam:WaitForChild("End").Position = raycastResult.Position
corruptedBeam:WaitForChild("End").Orientation = humanoidRootPart.Orientation
corruptedBeam:WaitForChild("Hitbox").Position = raycastResult.Position
wait()
end
Does anyone know how to make it so the end of the beam stays at the ray’s collision instead of going back?