I am having a problem with the ignore list, I have set the ignore list to ignore the player itself and when I aim at certain points the ray doesn't ignore my character which is the child of the player, I know that this is the problem for sure, because I checked when I set the ignore list to ignore the "workspace" and then it worked just fine, my goal is for the ray to ignore all of the Character's children. (Line 43)
Script:
enabled = true
script.RemoteEvent.OnServerEvent:connect(function(Player,Mousehitp,Mousehit)
if enabled == true then
enabled = false
repeat wait() until Player.Character
Character = Player.Character
tool = script.Parent.Parent
local laser = Instance.new("Part")
laser.Name = "Laser"
laser.TopSurface, laser.BottomSurface = 0, 0
laser.Size = Vector3.new(0.2, 0.2, 5)
laser.Transparency = 1
laser.BrickColor = BrickColor.Gray()
laser.Material = "Plastic"
laser.Anchored = true
laser.CanCollide = false
laser.Locked = true
laser.CFrame = tool.Tip.CFrame
laser.Parent = game.Workspace
print("Beam is in workspace")
local Trail = script.Trail:Clone()
Trail.Parent = laser
local attachment0 = Instance.new("Attachment" ,laser)
attachment0.Name = "TrailAttachment0"
local attachment1 = Instance.new("Attachment" ,laser)
attachment1.CFrame = attachment1.CFrame * CFrame.new(0,-0.25,0)
attachment1.Name = "TrailAttachment1"
Trail.Attachment0 = attachment0
Trail.Attachment1 = attachment1
game.Debris:AddItem(laser,5)
local maxDistance = 400
local curDistance = 0
local stepDistance = 6.5
local stepWait = 0.025
local StartPoint = tool.Tip.Position + Vector3.new(0,0.2,-0.45)
local EndPoint = Mousehit.lookVector
local function Step(overrideDistance)
local dir = (Mousehitp -StartPoint).Unit
-- Cast ray:
local ray = Ray.new(StartPoint, dir*1 * (overrideDistance or stepDistance))
local hit, pos, norm = game.Workspace:FindPartOnRayWithIgnoreList(ray, {Player})
-- Update laser position:
laser.CFrame = CFrame.new(StartPoint:lerp(pos, 0.5), pos)
local oldPos = StartPoint
StartPoint = pos
laser.Transparency = 1
if (hit) then
laser:Destroy()
end
curDistance = (curDistance + (pos - oldPos).magnitude)
-- Apply fade effect to laser as it approaches max distance from < 75 studs:
if (curDistance > (maxDistance - 75)) then
local d = (curDistance - (maxDistance - 75)) / 75
laser.Transparency = d
end
-- Recurse if max distance not reached:
if (curDistance < maxDistance) then
wait(stepWait)
Step()
end
end
Step()
-- Done! Destroy laser:
script.Parent.Done.Value = true
wait()
enabled = true
end
end)

9 comments
Just put Character in the ignore list
I have tried that.
You only need character
local ignore = {Character} local hit, pos, norm = game.Workspace:FindPartOnRayWithIgnoreList(ray, ignore) I have done this, same results.
Is there an option to change the ignore list after an amount of time?
certain amount of time*
You can add and remove values from a table following its creation using table.insert(ignore, val) and table.remove(ignore, key).
I will try.
The remove thingy is meant for numbers? Not for Variables?