I am attempting to make a laser gun and everything is working fine until I aim my gun at a SpawnLocation and then instead of the beam ignoring it and going through it the beam just goes to an entirely different position as if it is trying to avoid the spawn locations even though I am using the ignore list. I get no errors in the output. what do you guys think?
DetectRayHit.OnServerEvent:Connect(function(player, ray, startPos, orientation, BulletSpeed, Damage)
local part,position = workspace:FindPartOnRayWithIgnoreList(ray, {player.Character,workspace:WaitForChild("SpawnLocation")})
if part ~= nil then
local beam = game:GetService("ReplicatedStorage"):WaitForChild("Lasers").TX08Bullet:Clone()
beam.Parent = workspace
beam.Position = startPos
beam.Orientation = orientation
local tweenInfo = TweenInfo.new((beam.Position - position).Magnitude * 1 / BulletSpeed, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0,false,0)
local Tween = TweenService:Create(beam,tweenInfo,{Position = position})
Tween:Play()
beam.Touched:Connect(function(hit)
if hit ~= nil then
local Humanoid = hit.Parent:FindFirstChild("Humanoid")
if hit.Parent:FindFirstChild("Enemy") then
Humanoid:TakeDamage(Damage)
if Humanoid.Health == 0 then
for i,v in pairs(hit.Parent:GetChildren()) do
DS:AddItem(v,.5)
end
end
end
end
end)
Tween.Completed:Connect(function()
if beam ~= nil then
DS:AddItem(beam,.2)
end
end)
end
end)
