Trying to fix these, scripts I made. They won't work and I'm literally annoyed.
Server Script Service
local debris = game:GetService("Debris")
game.ReplicatedStorage.weaponFired.OnServerEvent:Connect(function(A1,A2,A3,A4)
if A3 == "DB" then
print(A1,A2,A3)
local bulletHole = Instance.new("Part",workspace)
bulletHole.Size = Vector3.new(.2,.2,.2)
bulletHole.Position = Vector3.new(A4.X,A4.Y,A4.Z)
bulletHole.Anchored = true
bulletHole.BrickColor = BrickColor.new("Black")
debris:AddItem(bulletHole,10)
bulletHole.CanCollide = false
if A2.Parent:FindFirstChild("Humanoid") then
A2.Parent.Humanoid:TakeDamage(50)
elseif A2.Parent:IsA("Accessory") then
A2.Parent.Parent.Humanoid:TakeDamage(50)
local bulletHole = Instance.new("Part",workspace)
bulletHole.Size = Vector3.new(.2,.2,.2)
bulletHole.Position = Vector3.new(A4.X,A4.Y,A4.Z)
bulletHole.Anchored = true
bulletHole.BrickColor = BrickColor.new("Black")
debris:AddItem(bulletHole,10)
bulletHole.CanCollide = false
elseif A3 == "Pistol" then
print("pew")
end
end
end)
game.ReplicatedStorage.playAudio.OnServerEvent:Connect(function(A1,A2,A3,A4)
if A2 == "Reload" and A4 == "DB" then
A3.Reload3:Play()
wait(.3)
A3.Reload3:Play()
if A2 == "Shoot" and A4 == "DB" then
A3.Handle.Fire:Play()
A3.F1.Transparency = 0.5
A3.F2.Transparency = 0.5
wait(.3)
A3.F1.Transparency = 1
A3.F2.Transparency = 1
if A2 == "Reload" and A4 == "Pistol" then
print("Reloading")
A3.Reload3:Play()
print("R")
if A2 == "Shoot" and A4 == "Pistol" then
A3.Handle.Fire:Play()
print("Pew")
print("hi")
end
end
end
end
end)
DB Shotgun script
local debounce = false
local Tool = script.Parent
local Handle = Tool:WaitForChild("Handle") or Tool.Handle
local ammo = 2
local uis = game:GetService("UserInputService")
local mouse = game.Players.LocalPlayer:GetMouse()
local spare = 20
function reload()
if ammo == 0 and spare >1 then
game.ReplicatedStorage.playAudio:FireServer("Reload",script.Parent,"DB")
ammo = 2
spare = spare -2
end
end
Tool.Activated:Connect(function()
local target = mouse.Target
if not debounce and ammo == 2 and target ~= nil then
debounce = true
game.ReplicatedStorage.playAudio:FireServer("Shoot",script.Parent,"DB")
game.ReplicatedStorage.playAudio:FireServer("Shoot",script.Parent,"DB")
ammo = ammo -2
game.ReplicatedStorage.weaponFired:FireServer(target,"DB",mouse.Hit)
print("Sent to Server")
debounce = false
elseif debounce == false and ammo == 0 then
debounce = true
Handle.Empty:Play()
wait(0.3)
Handle.Empty:Play()
debounce = false
end
end)
uis.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.R then
if ammo == 0 then
reload()
end
end
end)
Pistol
local debounce = false
local Tool = script.Parent
local Handle = Tool:WaitForChild("Handle") or Tool.Handle
local ammo = 12
local uis = game:GetService("UserInputService")
local mouse = game.Players.LocalPlayer:GetMouse()
local spare = 120
function reload()
if ammo == 0 and spare >11 then
game.ReplicatedStorage.playAudio:FireServer("Reload",script.Parent,"Pistol")
ammo = 12
spare = spare -12
end
end
Tool.Activated:Connect(function()
local target = mouse.Target
if not debounce and ammo >0 and target ~= nil then
debounce = true
game.ReplicatedStorage.playAudio:FireServer("Shoot",script.Parent,"Pistol")
ammo = ammo -1
game.ReplicatedStorage.weaponFired:FireServer(target,"Pistol",mouse.Hit)
print("Sent to Server")
debounce = false
elseif ammo == 0 then
debounce = true
Handle.Empty:Play()
debounce = false
end
end)
uis.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.R then
if ammo == 0 then
reload()
end
end
end)
