I've been trying to figure out why my tool that shoots raycast isn't firing correctly for other players, but fires correctly for me. Is there anything wrong with this, or is it just set up incorrectly?
function Fire(TargetPos) coroutine.resume(coroutine.create(function() if game.Players.LocalPlayer.Character["Humanoid"].Health > 0 then --coroutine.resume(coroutine.create(function() if Reloading == false and Ammo > 0 then local RotX = (math.random(-(AccuricyRange * 5), (AccuricyRange * 5)) * 0.1) local RotY = (math.random(-(AccuricyRange * 5), (AccuricyRange * 5)) * 0.1) local DirectionCF = CFrame.new(Barrel.Position, TargetPos) * CFrame.Angles(math.rad(RotX), math.rad(RotY), 0) local Dist = 1000 local Ray = Ray.new(Barrel.Position, (DirectionCF * CFrame.new(0, 0, -1000)).p - Barrel.Position) local Hit, Pos = game.Workspace:FindPartOnRay(Ray, game.Players.LocalPlayer.Character) if Hit ~= nil then Dist = (Pos - Barrel.Position).magnitude local Human = nil if Hit.Parent:findFirstChild("Humanoid") then Human = Hit.Parent["Humanoid"] elseif Hit.Parent.Parent:findFirstChild("Humanoid") then Human = Hit.Parent.Parent["Humanoid"] end if Human ~= nil then coroutine.resume(coroutine.create(function() local BulletBlocked = false local BlockedBySaber = TestForLightsaber(Human, DirectionCF.p, Pos) if BlockedBySaber == true then BulletBlocked = true end if BulletBlocked == false then local EPlayer = game.Players:GetPlayerFromCharacter(Human.Parent) local DamageHuman = true if EPlayer ~= nil then if EPlayer.TeamColor == game.Players.LocalPlayer.TeamColor and TeamKill == false then DamageHuman = false end end --wait(0.01) if DamageHuman == true and Human.Parent:findFirstChild("ForceField") == nil then Human.Health = Human.Health - (math.random((Damage - DamageRange) * 10, (Damage + DamageRange) * 10) * 0.1) if Human.Health <= 0 then if Human:findFirstChild("creator") == nil then local CreatorValue = Instance.new("ObjectValue", Human) CreatorValue.Name = "creator" CreatorValue.Value = game.Players.LocalPlayer end end end end end)) end end coroutine.resume(coroutine.create(function() Bullet.CFrame = DirectionCF script.Parent["Handle"]["Fire"]:Play() Barrel["PointLight"].Enabled = true if BulletColor == nil then Bullet.BrickColor = game.Players.LocalPlayer.TeamColor else Bullet.BrickColor = BulletColor end Barrel["PointLight"].Color = Bullet.BrickColor.Color Bullet.Transparency = 0.2 wait(0.03) Bullet.Transparency = 1 Barrel["Flash"]["Flash"].Visible = false Barrel["PointLight"].Enabled = false end)) BulletMesh.Scale = Vector3.new(0.25, 0.25, Dist) BulletMesh.Offset = Vector3.new(0, 0, -(Dist / 2)) end --end)) end end)) end