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)