Why does my revolver kill instantly on another map but does the damage that i want on my lobby?

Whenever I spawn into another map, I shoot a dummy and its health instantly turns into zero but I made the damage only to reduce its health by 20 per shot. I tracked the source and its my weapon spawner script. Whenever I disable the script, the revolver does the damage I want, but everytime its enabled, it makes my gun shot louder and the revolver damage to instantly kill.

Weapon spawner script:
local ongoing = game.ReplicatedStorage:WaitForChild(“OnGoing”)
local chosenmap = game.ReplicatedStorage:WaitForChild(“Chosenmap”)
local weapons = game.ServerStorage:WaitForChild(“Weapons”)
local weaponsfolder = workspace.Weapons

while true do
if ongoing.Value == true then
local spawnpart = workspace[chosenmap.Value].SpawnPart
if spawnpart then
for i, weapons in pairs(weapons:GetChildren()) do
local clone = weapons:Clone()
clone.Origin.Position = spawnpart.Position + Vector3.new(math.random(-150,150),0,math.random(-150,150))
clone.Handle.Position = clone.Origin.Position
clone.Parent = weaponsfolder
wait(1)
end
end
else
if weaponsfolder:FindFirstChildWhichIsA(“Part”) then
wait(10)
weaponsfolder:ClearAllChildren()
end
end
wait()
end

revolver script:
(LocalScript)
local revolver = script.Parent
local revolverfire = game.ReplicatedStorage:WaitForChild(“RevolverFire”)
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local db = false
local origin = revolver:WaitForChild(‘Origin’)
local player = script:FindFirstAncestorWhichIsA"Player" or game:GetService"Players":GetPlayerFromCharacter(script.Parent.Parent)
local gui = player.PlayerGui:WaitForChild(“AmmoGui”)
local textlabel = gui.TextLabel
local ammo = 10

revolver.Equipped:Connect(function()
textlabel.Visible = true
textlabel.Text = "Bullets: "…ammo
end)

revolver.Unequipped:Connect(function()
textlabel.Visible = false
end)

revolver.Deactivated:Connect(function()
if ammo == 0 then
wait(2)
textlabel.Visible = false
revolver:Destroy()
end
end)

revolver.Activated:Connect(function()
if not db then
db = true
if ammo > 0 then
ammo -= 1
textlabel.Text = "Bullets: "…ammo
local mouseposition = mouse.Hit.p
local originposition = origin.Position
revolverfire:FireServer(mouseposition,originposition)
end
wait(2)
db = false
end
end)

(ServerScript)
local revolverfire = game.ReplicatedStorage:WaitForChild(“RevolverFire”)
local range = 400
local revolver = script.Parent
local debris = game:GetService(“Debris”)
local tool = script.Parent
local fire = revolver.Fire
local db = false

local function bullet(player,direction, origin)
local midpoint = origin + direction/2
local beam = Instance.new(“Part”)
beam.Parent = workspace.AfterShoot
beam.Anchored = true
beam.CanCollide = false
beam.CFrame = CFrame.new(midpoint, origin)
beam.Size = Vector3.new(.2,.2,direction.magnitude)
beam.BrickColor = BrickColor.new(“Bright yellow”)
beam.Material = “Neon”
beam.Touched:Connect(function(hit)
local hum = hit.Parent.Humanoid
if hum and hum ~= player.Character.Humanoid then
if not db then
db = true
hum.Health -=20
wait(2)
db = false
end
end
end)
debris:AddItem(beam, .2)
end

revolverfire.OnServerEvent:Connect(function(player, mouseposition, originposition)
local direction = (mouseposition-originposition).Unit * range
bullet(player,direction, originposition)
fire:Play()
local playerchar = player.character
local raycastparams = RaycastParams.new()
raycastparams.FilterDescendantsInstances = {playerchar, tool.Handle, tool.Origin, workspace.AfterShoot:GetChildren()}
local result = workspace:Raycast(originposition, direction, raycastparams)
end)

Could it be possible that the script is cloning itself which would result in dealing more damage than what you expected it to be? Or maybe you’re firing the Event is firing multiple times?

I’d recommend debugging it with print() statements & checking the hierarchy of where the script exactly is, if it so happens to clone or not

The script isnt cloning itself since it only gave me 1 result but the revolver on the other hand:

It looks as though your OnServerEvent seems to be firing way more than its supposed to

Not sure if this is related, but you defined weapons twice here:

Try changing those to different names, if that doesn’t work the only instance could be is with the Activated event inside your LocalScript possibly?

I’ve changed the names but the results are still the same, is there any other way I can fix this? Since I currently cant think of any.

Only thing I’ll say is just debug with print() statements when you call FireServer(), as you seem to be firing that RemoteEvent multiple times for some reason when it’s called

1 Like

Found a way to get around this by putting the remote event inside the tool so that multiple clones wouldn’t just be using the same remote event. Anyways, thanks for trying to help me out dude!