Guns are not supposed to damage the player using, but this is what is happening with my gun.
I dont know why it does it but uh here’s the localscript that does everything
local tool = script.Parent
local player = game.Players.LocalPlayer
local shooting = false
local mouse = player:GetMouse()
local raycastfilter = RaycastParams.new()
raycastfilter.FilterDescendantsInstances = {player.Character}
raycastfilter.FilterType = Enum.RaycastFilterType.Blacklist
local ammo = 6
local max_ammo = 6
local cooldown = 0.1
local reloading = false
local mouse_icon = "http://www.roblox.com/asset/?id=9720078100"
local UIS = game:GetService("UserInputService")
local StarterGui = game:GetService("StarterGui")
local equipped = false
local function reload()
player.PlayerGui.RevolverGUI.TextLabel.Text = "Reloading!"
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,false)
tool.Handle.Reload:Play()
reloading = true
task.wait(2)
ammo = max_ammo
player.PlayerGui.RevolverGUI.TextLabel.Text = tostring(max_ammo)
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,true)
reloading = false
end
tool.Equipped:Connect(function()
equipped = true
player.PlayerGui.RevolverGUI.Enabled = true
player.PlayerGui.RevolverGUI.TextLabel.Text = tostring(ammo)
mouse.Icon = mouse_icon
end)
tool.Unequipped:Connect(function()
equipped = false
mouse.Icon = ""
player.PlayerGui.RevolverGUI.Enabled = false
script.Parent.Handle.Reload:Stop()
end)
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.R and equipped then
if script:FindFirstAncestorWhichIsA("Tool").Parent:FindFirstChildWhichIsA("Humanoid").Health > 0 then
reload()
end
end
end)
tool.Activated:Connect(function()
if not shooting and not reloading and script:FindFirstAncestorWhichIsA("Tool").Parent:FindFirstChildWhichIsA("Humanoid").Health > 0 then
if ammo == 0 then
reload()
return
end
ammo -= 1
tool.Handle.Fire:Play()
player.PlayerGui.RevolverGUI.TextLabel.Text = tostring(ammo)
local raycast = workspace:Raycast(tool.Handle.Position,(mouse.Hit.Position - tool.Handle.Position)*300, raycastfilter)
if raycast then
local instance = raycast.Instance
local instanceParent = instance.Parent
local findHumanoid = instanceParent:FindFirstChildOfClass("Humanoid")
if findHumanoid then
game.ReplicatedStorage.RemoteEvent:FireServer(findHumanoid)
end
end
shooting = true
task.wait(cooldown)
shooting = false
end
end)