script:
local replicatedEvents = game.ReplicatedStorage.Events
local shootRE = replicatedEvents.ShootGun
local shootVisualsRE = replicatedEvents.ShootGunVisuals
shootRE.OnServerEvent:Connect(function(plr: Player, tool: Tool, camCF: CFrame, mouseCF: CFrame)
local char = plr.Character
local root = char:FindFirstChild("HumanoidRootPart")
if tool and tool.Name == "Revolver" and root then
local config = tool.Configuration
if config.IsOnCooldown.Value == false then
config.IsOnCooldown.Value = true
tool.Handle.ShootSound:Play()
local rp = RaycastParams.new()
rp.FilterType = Enum.RaycastFilterType.Exclude
rp.FilterDescendantsInstances = {char}
local direction = (mouseCF.Position - camCF.Position).Unit
local rayCast = workspace:Raycast(camCF.Position, direction * config.RaycastDepth.Value, rp)
if rayCast then
local hum = rayCast.Instance.Parent:FindFirstChild("Humanoid") or rayCast.Instance.Parent.Parent:FindFirstChild("Humanoid")
if hum and hum.Health > 0 then
if game.Players:GetPlayerFromCharacter(hum.Parent) and not hum.Parent:FindFirstChild("MurdererKnife") and not game.Players:GetPlayerFromCharacter(hum.Parent).Backpack:FindFirstChild("MurdererKnife") then
char.Humanoid.Health = 0
end
hum.Health = 0
end
end
shootVisualsRE:FireAllClients(tool, rayCast and rayCast.Position or mouseCF.Position)
task.wait(config.ShootCooldown.Value)
if config and config:FindFirstChild("IsOnCooldown") then
config.IsOnCooldown.Value = false
end
end
end
end)