I have a taser script which freezes players for 5 seconds, the problem I’m having is that when the taser hits a part with collision off then it won’t go through it, my game has many non collision parts so this is a big problem. Anyway to fix this? Any help would be appreciated!
Local Script:
if currentmag > 0 then
gungui:WaitForChild("Frame"):WaitForChild("AmmoInMag").TextColor3 = Color3.fromRGB(255, 255, 255)
playanimation:FireServer(tool:WaitForChild("Animations"):WaitForChild("Recoil"), tool:WaitForChild("Animations"):WaitForChild("Recoil"):WaitForChild("Speed").Value)
fireable = false
local ray = Ray.new(tool:WaitForChild("Handle").CFrame.p, (mouse.Hit.p - tool:WaitForChild("Handle").CFrame.p).Unit * 2048)
local part, position = workspace:FindPartOnRay(ray, player.Character, false, true)
currentmag = currentmag - 1
gungui:WaitForChild("Frame"):WaitForChild("AmmoInMag").Text = currentmag
gungui:WaitForChild("Frame"):WaitForChild("AmmoInMagShadow").Text = currentmag
castray:FireServer(ray, position)
local beam = Instance.new("Part")
beam.BrickColor = BrickColor.new("Bright red")
beam.FormFactor = Enum.FormFactor.Custom
beam.Material = Enum.Material.Neon
beam.Transparency = 1
beam.Anchored = true
beam.Locked = true
beam.CanCollide = false
beam.Parent = workspace
local distance = (tool:WaitForChild("Handle").CFrame.p - position).Magnitude
beam.Size = Vector3.new(0.3, 0.3, distance)
beam.CFrame = CFrame.new(tool:WaitForChild("Handle").CFrame.p, position) * CFrame.new(0, 0, -distance / 2)
if part then
local humanoid = part.Parent:FindFirstChildOfClass("Humanoid")
if not humanoid then
humanoid = part.Parent.Parent:FindFirstChildOfClass("Humanoid")
end
if humanoid then
if part.Name == "Head" then
takedamage:FireServer(humanoid, config:WaitForChild("Damage").Value * config:WaitForChild("HeadshotMultiplier").Value)
script.Headshot:Play()
else
takedamage:FireServer(humanoid, config:WaitForChild("Damage").Value)
script.HitMarker:Play()
end
end
end
playsound:FireServer(tool:WaitForChild("Handle"):WaitForChild("Fire"))
tool:WaitForChild("Handle"):WaitForChild("Fire"):Play()
wait(config:WaitForChild("Firerate").Value)
fireable = true
playanimation:FireServer(tool:WaitForChild("Animations"):WaitForChild("Idle"), tool:WaitForChild("Animations"):WaitForChild("Idle"):WaitForChild("Speed").Value)
beam:Destroy()
else
gungui:WaitForChild("Frame"):WaitForChild("AmmoInMag").TextColor3 = Color3.fromRGB(255, 0, 0)
tool:WaitForChild("Handle"):WaitForChild("Empty"):Play()
if config:WaitForChild("AutoReload").Value then
autoReload()
end
wait(config:WaitForChild("Firerate").Value)
end