So today i modded a free model gun system for a Roleplaying game, i removed the damage codes and stuff so it won’t damage players. But suddenly i get this error ?
It worked fine like a few minutes ago, and that just happened. So basically i can’t fire my gun whatsoever.
Can anyone help ?
Here’s the code if you need to check it.
SERVERMAIN
local maxammo = script.Parent.MaxAmmo.Value
local ammo = script.Parent.Ammo
local reloading = false
local spread = script.Parent.EDIT.Spread.Value
script.Parent.Shoot.OnServerEvent:Connect(function (plr,Target)
if plr.Character ~= nil and plr.Character.Humanoid.Health >= .1 and script.Parent.Enabled == true and reloading == false then
script.Parent.Enabled = false
local hit = false
if ammo.Value >= 1 then
ammo.Value = ammo.Value - 1
script.Parent.Handle.FireSound:Play()
script.Parent.Handle.MuzzlePoint.SparkEFX:Emit(20)
script.Parent.Handle.MuzzlePoint.Smoke:Emit(50)
script.Parent.Handle.ChamberPoint.Smoke:Emit(20)
script.Parent.Handle.ChamberPoint.Shell:Emit(1)
for i = 1, script.Parent.EDIT.BulletsPerShot.Value do
local dist = (script.Parent.RPart.Position - Target).Magnitude
local ray = Ray.new(script.Parent.RPart.CFrame.p, (Target - script.Parent.RPart.CFrame.p + (Vector3.new(math.random(-spread,spread)/1000,math.random(-spread,spread)/1000,math.random(-spread,spread)/1000) * dist)).unit * 2000)
local part, position = workspace:FindPartOnRay(ray, plr.Character, false, true)
print(position)
print(part)
print(Target)
local beam = Instance.new("Part")
beam.Anchored = true
beam.CanCollide = false
beam.Material = "Neon"
if dist >= 60 then
beam.Size = Vector3.new(.05,.05,60)
else
beam.Size = Vector3.new(.05,.05,dist)
end
beam.CFrame = CFrame.new(script.Parent.RPart.CFrame.p, position) * CFrame.new(0,0,-beam.Size.Z/2)
game.Debris:AddItem(beam,10)
local fx = script.Parent.FX:Clone()
fx.Dist.Value = dist
fx.Parent = beam
fx.Disabled = false
beam.Parent = workspace
if part ~= nil then
if part.Parent:FindFirstChild("Humanoid") then
hit = true
local blood = script.Parent.EDIT.Blood:Clone()
blood.Parent = part
blood.Enabled = true
game.Debris:AddItem(blood,.2)
elseif part.Parent.Parent:FindFirstChild("Humanoid") then
hit = true
local blood = script.Parent.EDIT.Blood:Clone()
blood.Parent = part
blood.Enabled = true
game.Debris:AddItem(blood,.2)
end
end
local hole = Instance.new("Part")
hole.Size = Vector3.new(.2,.2,.2)
hole.Material = "Neon"
hole.Anchored = true
hole.BrickColor = BrickColor.new("Black")
hole.Shape = 0
hole.CanCollide = false
hole.Position = position
local dust = script.Parent.EDIT.Dust:Clone()
dust.Parent = hole
dust.Enabled = true
dust.Script.Disabled = false
game.Debris:AddItem(hole, 1)
if hit == false then
hole.Parent = workspace
end
end
elseif ammo.Value <= 0 then
script.Parent.Handle.NoAmmo:Play()
end
wait(script.Parent.EDIT.Firerate.Value)
script.Parent.Enabled = true
end
end)
script.Parent.Reload.OnServerEvent:Connect(function ()
if reloading == false then
reloading = true
wait(script.Parent.EDIT.ReloadTime.Value)
ammo.Value = maxammo
reloading = false
end
end)
script.Parent.Equipped:Connect(function()
script.Parent.Handle.EquipSound:Play()
end)
CLIENTMAIN
local held = false
local plr = game.Players.LocalPlayer
script.Parent.Equipped:Connect(function()
chr = script.Parent.Parent
end)
script.Parent.Activated:Connect(function ()
held = true
if script.Parent.Enabled == true then
script.Parent.Enabled = false
while held == true do
if script.Parent.EDIT.BurstShots.Value >= 2 then
for i = 1, script.Parent.EDIT.BurstShots.Value do
script.Parent.Shoot:FireServer(chr.Humanoid.TargetPoint)
fire:Play()
wait(script.Parent.EDIT.BurstRate.Value)
end
else
fire:Play()
script.Parent.Shoot:FireServer(chr.Humanoid.TargetPoint)
end
if script.Parent.EDIT.Auto.Value == false then
held = false
end
wait(script.Parent.EDIT.Firerate.Value + .1)
end
if script.Parent.EDIT.Auto.Value == false then
wait(script.Parent.EDIT.Firerate.Value + .1)
end
script.Parent.Enabled = true
end
end)
script.Parent.Deactivated:Connect(function()
held = false
end)
script.Parent.Equipped:Connect(function()
local EquipAnim = chr.Humanoid:LoadAnimation(script.Parent.EquipAnim)
EquipAnim:Play()
wait()
holdanim = chr.Humanoid:LoadAnimation(script.Parent.HoldAnim)
holdanim:Play()
rel = chr.Humanoid:LoadAnimation(script.Parent.ReloadAnim)
fire = chr.Humanoid:LoadAnimation(script.Parent.FireAnim)
end)
script.Parent.Unequipped:Connect(function()
held = false
holdanim:Stop()
fire:Stop()
rel:Stop()
end)
game.Players.LocalPlayer:GetMouse().KeyDown:connect(function(KeyPressed)
if KeyPressed == "r" and script.Parent.Parent == plr.Character then
script.Parent.Reload:FireServer()
rel:Play()
end
end)
I intended this forum to be my last resort since i can’t find any help from my devs.
Your reply will be appreciated.