-
What do you want to achieve?
making a laser attachment that can work on any parent -
What is the issue?
i scripted a laser and it work but when i put it somewhere else when playing it not work
when i change the parent
https://streamable.com/tekvgz
when i put on workspace
https://streamable.com/i89qkb
local NormalPart = script.Parent.Parent.Hitt
local RayPart = script.Parent
local MaxRayLength = 50
local rayP = RaycastParams.new()
rayP.FilterType = Enum.RaycastFilterType.Blacklist
rayP.FilterDescendantsInstances = {RayPart, NormalPart}
rayP.IgnoreWater = true
while wait() do
local result = workspace:Raycast(RayPart.Position, RayPart.CFrame.LookVector * MaxRayLength, rayP)
if result then
RayPart.Attachment1.WorldPosition = result.Position
NormalPart.CFrame = CFrame.new(result.Position, result.Position + result.Normal)
else
RayPart.Attachment1.WorldPosition = RayPart.Position + (RayPart.CFrame.LookVector * MaxRayLength)
NormalPart.CFrame = CFrame.new(RayPart.Attachment1.WorldPosition)
end
end