player = game:GetService("Players").LocalPlayer
Mouse = player:GetMouse()
tool = script.Parent
Ammu = 30
Shoot = false
Rel = false
Eq = false
tool.Equipped:connect(function()
print("Tool equipped!")
Mouse.Icon = "http://www.roblox.com/asset?id=274723894"
Eq = true
Mouse.Button1Down:connect(function()
if Eq == true then
Shoot = true
end
end)
Mouse.Button1Up:connect(function()
Shoot = false
end)
while true do
wait()
if Eq == true then
if Shoot== true then
if Rel == false then
if Ammu > 0 then
Ammu = Ammu - 1
tool.Ammo.Value = Ammu
script.Parent.Sound:Play()
print("Mouse pressed!")
local ray = Ray.new(tool.Handle.CFrame.p, (Mouse.Hit.p - tool.Handle.CFrame.p).unit * 300)
local part, position = workspace:FindPartOnRay(ray, player.Character, false, true)
local beam = Instance.new("Part", workspace)
beam.BrickColor = BrickColor.new("Bright red")
beam.FormFactor = "Custom"
beam.Material = "Neon"
beam.Transparency = 0.25
beam.Anchored = true
beam.Locked = true
beam.CanCollide = false
local distance = (tool.Handle.CFrame.p - position).magnitude
beam.Size = Vector3.new(0.3, 0.3, distance)
beam.CFrame = CFrame.new(tool.Muz.CFrame.p, position) * CFrame.new(0, 0, -distance / 2)
game:GetService("Debris"):AddItem(beam, 0.05)
wait(.09)
if part then
local humanoid = part.Parent:FindFirstChild("Humanoid")
if not humanoid then
humanoid = part.Parent.Parent:FindFirstChild("Humanoid")
end
if humanoid then
humanoid:TakeDamage(7.5)
script.Parent.Hit:Play()
wait()
end
end
end
end
end
end
end
end)
game:service("RunService").Stepped:connect(function()
if Ammu == 0 then
if Rel == false then
Shoot = false
Rel = true
script.Parent.Relo:Play()
Mouse.Icon = "http://www.roblox.com/asset?id=274724449"
wait(2)
Mouse.Icon = "http://www.roblox.com/asset?id=274723894"
Ammu = 30
Rel = false
end
end
end)
tool.Unequipped:connect(function()
Eq = false
Shoot = false
end)
game:service("RunService").Stepped:connect(function()
script.Parent.Ammo.Value = Ammu
end)
function onKeyPress(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.R then
print("R was pressed")
if Ammu ~= 30 then
if Rel == false then
Shoot = false
Rel = true
script.Parent.Relo:Play()
Mouse.Icon = "http://www.roblox.com/asset?id=274724449"
wait(2)
Mouse.Icon = "http://www.roblox.com/asset?id=274723894"
Ammu = 30
Rel = false
end
end
end
end
game:GetService("UserInputService").InputBegan:connect(onKeyPress)
player.Character.Humanoid.Died:connect(function()
Shoot = false
end)
COMMUNITY QUESTION
How would I get this to work with Filtering Enabled?
0 answers
No public answers were preserved for this question.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
ik the title explains it all, but please give me some details about your question: What went wrong in the script while you're testing FilteringEnabled?
Players take damage but its local to the weapon user so if im being shot my health goes down for the person shooting me but not me