My gun system works well if you only use one gun. When you use two and you aim down sight it spams the aim down sound and also stays equip (bugged)
so my gun requires a module every gun and its called the gunclient module, here is the “client” script I have on my gun tool.
require(game:GetService("ReplicatedStorage"):WaitForChild("Modules"):WaitForChild("GunClient"))(script.Parent)
this runs the gunclient modulescript for each gun.
and the gunclient modulescript is
return function(Tool)
task.wait(1)
local ticksload = 0
local rtickload = 300
repeat task.wait() ticksload+=1 until (_G.FOVs and _G.WalkSpeeds and _G.VM) or ticksload>=rtickload
if ticksload>=rtickload then
print('Failed to load')
end
-- \\ SERVICES // --
local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
-- \\ VARIABLES // --
local CurrentCamera = workspace.CurrentCamera
local LocalPlayer = game:GetService("Players").LocalPlayer
local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid", math.huge)
local Mouse = LocalPlayer:GetMouse()
local Animations = {}
for _, Animation in pairs(Tool:FindFirstChild("Animations"):GetChildren()) do
Animations[Animation.Name] = Humanoid:LoadAnimation(Animation)
end
local Holding = false
local Aiming = false
local Can = false
local Equipped = false
local ActuallyEquipped = false
local Reloading = false
local Debounce = false
local Running = false
local Moving = false
local CSize = 1
local Config = require(Tool:WaitForChild("Modules"):WaitForChild("Config"))
local EquipSounds = require(Tool:WaitForChild("Modules"):WaitForChild("EquipSounds"))
local ReloadSounds = require(Tool:WaitForChild("Modules"):WaitForChild("ReloadSounds"))
local Values = Tool:WaitForChild("Values")
local GunSounds = ReplicatedStorage:WaitForChild("Effects"):WaitForChild("Sounds"):WaitForChild("Guns")
local AimDown = GunSounds:WaitForChild("AimDown"):Clone()
local AimUp = GunSounds:WaitForChild("AimUp"):Clone()
AimDown.Parent = CurrentCamera
AimUp.Parent = CurrentCamera
local AimFOV = Instance.new("NumberValue")
AimFOV.Value = 0
_G.FOVs[AimFOV] = AimFOV
local AimWalkSpeed = Instance.new("NumberValue")
AimWalkSpeed.Value = 0
_G.WalkSpeeds[AimWalkSpeed] = AimWalkSpeed
local ReloadWalkSpeed = Instance.new("NumberValue")
ReloadWalkSpeed.Value = 0
_G.WalkSpeeds[ReloadWalkSpeed] = ReloadWalkSpeed
local GunGUI = ReplicatedStorage:WaitForChild("UI"):WaitForChild("Guns"):WaitForChild("GunGUI"):Clone()
GunGUI.Parent = LocalPlayer.PlayerGui
local CrosshairModule = _G.CHM.new(true)
CrosshairModule:setcrosssettings(Config.Crosshair.CrossSize, Config.Crosshair.CrossSpeed, Config.Crosshair.CrossDamper)
local FPos = Vector3.new(-1.56, 0.16, -0.06)
GunGUI.Parent = script
local Modes = Config.Modes
local ActualMode = 1
local Mode = Modes[ActualMode]
-- \\ FUNCTIONS // --
local function UpdateGui()
local Mag = Values:WaitForChild("Mag").Value
local Ammo = Values:WaitForChild("Ammo").Value
GunGUI.GunF.AmmoFrame.AmmoText.Text = "<b>"..Mag.."</b> / "..Ammo
GunGUI.GunF.AmmoFrame.GunName.Text = Config.FullName
GunGUI.GunF.AmmoFrame.GunMode.Text = Mode
end
local function Shoot()
local SpreadReduction = not _G.ADS and 1 or Config.AimSettings.SpreadReduction
local RecoilReduction = not _G.ADS and 1 or Config.AimSettings.RecoilReduction
local Direction = CurrentCamera.CFrame.LookVector + Vector3.new((math.random(-1000, 1000) / 10000) / SpreadReduction, (math.random(-1000, 1000) / 10000) / SpreadReduction, (math.random(-1000, 1000) / 10000) / SpreadReduction)
local O = _G.VM.CloneTool.Handle.FireFrom.WorldPosition
if _G.ADS then
O = CurrentCamera.CFrame.Position
end
ReplicatedStorage:WaitForChild("Communication"):FindFirstChildOfClass("BindableEvent"):Fire("Visualize", Tool, _G.VM.CloneTool.Handle.FirePoint, Direction, nil, nil, nil, Config.BulletSettings.Speed, O)
ReplicatedStorage:WaitForChild("Communication"):FindFirstChildOfClass("BindableEvent"):Fire("Recoil", Config.Recoil / RecoilReduction)
ReplicatedStorage:WaitForChild("Communication"):FindFirstChildOfClass("RemoteEvent"):FireServer("Visualize", Tool, Tool.Handle.FirePoint, Direction, nil, LocalPlayer, nil, Config.BulletSettings.Speed)
Animations.Shoot:Play(not _G.ADS and Config.AimSettings.FireAnimWeight or Config.FireAnimWeight)
CrosshairModule.crossspring:Accelerate(Config.Crosshair.Expansion)
Debounce = true
UpdateGui()
end
UpdateGui()
local GunClient = {
Equip = function()
UpdateGui()
GunGUI.Parent = LocalPlayer.PlayerGui
Animations.Equip:Play(nil, nil, Config.Equip.EquipAnimSpeed)
Animations.Idle:Play()
CrosshairModule:connect()
coroutine.wrap(EquipSounds)(true, Config.Equip.EquipAnimSpeed)
ReplicatedStorage:WaitForChild("Communication"):FindFirstChildOfClass("RemoteEvent"):FireServer("EquipEffects", Tool, true, Config.Equip.EquipAnimSpeed)
Equipped = true
local Time = (Config.Equip.EquipTime / Config.Equip.EquipAnimSpeed)
local t = tick()
while true do
RunService.RenderStepped:Wait()
if (tick() - t) >= Time or not Equipped then
break
end
end
if (tick() - t) >= Time and Equipped then
ActuallyEquipped = true
end
end,
Unequip = function()
UpdateGui()
GunGUI.Parent = script
CrosshairModule:disconnect()
for _, Animation in pairs(Animations) do
Animation:Stop()
end
Equipped = false
ActuallyEquipped = false
coroutine.wrap(EquipSounds)(false)
ReplicatedStorage:WaitForChild("Communication"):FindFirstChildOfClass("RemoteEvent"):FireServer("EquipEffects", Tool, false)
if Reloading then
coroutine.wrap(ReloadSounds)(false)
ReplicatedStorage:WaitForChild("Communication"):FindFirstChildOfClass("RemoteEvent"):FireServer("ReloadEffects", Tool, false)
Animations.Reload:Stop(0.5)
Reloading = false
end
end,
Activated = function()
if Reloading then
coroutine.wrap(ReloadSounds)(false)
ReplicatedStorage:WaitForChild("Communication"):FindFirstChildOfClass("RemoteEvent"):FireServer("ReloadEffects", Tool, false)
Animations.Reload:Stop(0.5)
Reloading = false
end
if Debounce then
return
end
if Values.Mag.Value <= 0 then
return
end
if Mode == "SEMI" then
Shoot()
local t = tick()
while true do
RunService.RenderStepped:Wait()
if (tick() - t) > (1 / Config.FireRate) then
break
end
end
Debounce = false
elseif Mode == "BURST" then
Debounce = true
local Amount = Config.BurstSettings.Amount
if Amount > Values.Mag.Value then
Amount = Values.Mag.Value
end
for i = 1, Amount do
Shoot()
local t = tick()
while true do
RunService.RenderStepped:Wait()
if (tick() - t) > (1 / Config.BurstSettings.Rate) then
break
end
end
end
local t = tick()
while true do
RunService.RenderStepped:Wait()
if (tick() - t) > (1 / Config.BurstSettings.AfterFire) then
break
end
end
Debounce = false
end
end,
Deactivated = function()
end,
WhileLoop = function()
end,
OnClientEvent = function(f)
if f == "UpdateGui" then
UpdateGui()
end
end,
RenderStep = function(Delta)
if _G.SPR or Reloading or not ActuallyEquipped then
CrosshairModule:inactive()
else
CrosshairModule:active()
end
if _G.SPR and Moving then
if not Running then
Running = true
end
else
if Running then
Running = false
end
end
if LocalPlayer.Character then
if LocalPlayer.Character:FindFirstChild("Humanoid") then
Moving = LocalPlayer.Character.Humanoid.MoveDirection.Magnitude > 0
end
end
local CSize = 0
if ActuallyEquipped then
CSize = 1
if Aiming then
CSize = 0
else
if Reloading then
CSize = 0.1
else
if Moving then
CSize = 1.25
end
end
end
else
CSize = 0.1
end
CrosshairModule:setcrossscale(CSize)
if LocalPlayer.Character then
if _G.VM then
if _G.VM.CloneTool then
if _G.VM.CloneTool:FindFirstChild("Handle") then
if _G.VM.CloneTool.Handle:FindFirstChild("FirePoint") and _G.VM.CloneTool.Handle:FindFirstChild("FireFrom") then
local Raycast = Ray.new(CurrentCamera.CFrame.Position, _G.VM.CloneTool.Handle.FirePoint.WorldPosition - CurrentCamera.CFrame.Position)
local Result, Position, Normal = workspace:FindPartOnRayWithIgnoreList(Raycast, {Tool, CurrentCamera, LocalPlayer.Character})
if Result then
_G.VM.CloneTool.Handle.FireFrom.WorldPosition = Position
else
_G.VM.CloneTool.Handle.FireFrom.Position = FPos
end
end
end
end
end
end
end,
}
-- \\ MAIN // --
coroutine.resume(coroutine.create(function()
while true do
if Mode == "AUTO" then
Holding = not _G.SPR and UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton1) and Values.Mag.Value > 0 and Equipped and ActuallyEquipped and not Reloading and _G.VM and _G.VM.CloneTool and _G.VM.CloneTool:FindFirstChild("Handle") and _G.VM.CloneTool.Handle:FindFirstChild("FireFrom")
if Holding then
Shoot()
local t = tick()
while true do
RunService.RenderStepped:Wait()
if (tick() - t) > (1 / Config.FireRate) then
break
end
end
Debounce = false
end
end
Aiming = not _G.SPR and UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton2) and Equipped and ActuallyEquipped and not Reloading and _G.VM and _G.VM.CloneTool and _G.VM.CloneTool:FindFirstChild("Handle") and _G.VM.CloneTool.Handle:FindFirstChild("FireFrom")
if Aiming then
if not _G.ADS then
AimDown:Play()
TweenService:Create(AimFOV, Config.AimSettings.Tween, {Value = 70 - Config.AimSettings.FOV}):Play()
TweenService:Create(AimWalkSpeed, Config.AimSettings.Tween, {Value = Config.AimSettings.WalkSpeed}):Play()
TweenService:Create(Values.AimOffset, Config.AimSettings.Tween, {Value = Config.AimSettings.AimOffset}):Play()
TweenService:Create(GunGUI.ScreenEffects.Aim, Config.AimSettings.Tween, {ImageTransparency = 0}):Play()
Animations.Idle:Play(0.2, nil, 0)
_G.ADS = true
end
else
if _G.ADS then
AimUp:Play()
TweenService:Create(AimFOV, Config.AimSettings.Tween, {Value = 0}):Play()
TweenService:Create(AimWalkSpeed, Config.AimSettings.Tween, {Value = 0}):Play()
TweenService:Create(Values.AimOffset, Config.AimSettings.Tween, {Value = CFrame.new()}):Play()
TweenService:Create(GunGUI.ScreenEffects.Aim, Config.AimSettings.Tween, {ImageTransparency = 1}):Play()
Animations.Idle:Play(0.2, nil, 1)
_G.ADS = false
end
end
task.wait()
end
end))
local function InputBegan(Key, IsTyping)
if IsTyping then
return
end
if Key.KeyCode == Enum.KeyCode.R then
if not Equipped or not ActuallyEquipped then
return
end
if Reloading then
return
end
if Values.Mag.Value >= Config.Ammo.Mag then
return
end
if Values.Ammo.Value <= 0 then
return
end
Reloading = true
TweenService:Create(ReloadWalkSpeed, Config.Reload.Tween, {Value = Config.Reload.ReloadWalkSpeed}):Play()
Animations.Reload:Play(0.5, nil, Config.Reload.ReloadAnimSpeed)
coroutine.wrap(ReloadSounds)(true, Config.Reload.ReloadAnimSpeed)
ReplicatedStorage:WaitForChild("Communication"):FindFirstChildOfClass("RemoteEvent"):FireServer("ReloadEffects", Tool, true, Config.Reload.ReloadAnimSpeed)
local t = tick()
while true do
RunService.RenderStepped:Wait()
if (tick() - t) >= (Config.Reload.ReloadTime / Config.Reload.ReloadAnimSpeed) or not Reloading or _G.SPR then
break
end
end
if (tick() - t) >= (Config.Reload.ReloadTime / Config.Reload.ReloadAnimSpeed) and Reloading then
ReplicatedStorage:WaitForChild("Communication"):FindFirstChildOfClass("RemoteFunction"):InvokeServer("ReloadFinish", Tool)
end
Reloading = false
TweenService:Create(ReloadWalkSpeed, Config.Reload.Tween, {Value = 0}):Play()
coroutine.wrap(ReloadSounds)(false)
ReplicatedStorage:WaitForChild("Communication"):FindFirstChildOfClass("RemoteEvent"):FireServer("ReloadEffects", Tool, false)
Animations.Reload:Stop(0.5)
Reloading = false
elseif Key.KeyCode == Enum.KeyCode.V then
if Reloading then
return
end
ActualMode = (ActualMode >= #Modes) and 1 or ActualMode + 1
Mode = Modes[ActualMode]
UpdateGui()
end
end
-- \\ CONNECTIONS // --
Tool.Equipped:Connect(GunClient.Equip)
Tool.Unequipped:Connect(GunClient.Unequip)
Tool.Activated:Connect(GunClient.Activated)
Tool.Deactivated:Connect(GunClient.Deactivated)
UserInputService.InputBegan:Connect(InputBegan)
ReplicatedStorage:WaitForChild("Communication"):FindFirstChildOfClass("RemoteEvent").OnClientEvent:Connect(GunClient.OnClientEvent)
RunService.RenderStepped:Connect(GunClient.RenderStep)
end
Theres actually another modulescript, ‘client’. This script gets ran when a player joins, the modulescript is client sided only.
-- \\ SERVICES // --
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local Workspace_ = game:GetService("Workspace")
local StarterGui = game:GetService("StarterGui")
local CollectionService = game:GetService("CollectionService")
local UserInputService = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local Debris = game:GetService("Debris")
-- \\ FOLDERS // --
local Communication = ReplicatedStorage:WaitForChild("Communication")
local Modules = ReplicatedStorage:WaitForChild("Modules")
local Effects = ReplicatedStorage:WaitForChild("Effects")
local BloodInstances = Workspace_:WaitForChild("Game"):WaitForChild("InstanceFilter"):WaitForChild("BloodInstances")
local Sounds = Effects:WaitForChild("Sounds")
-- \\ MODULES // --
local BloodCaster = require(Modules:WaitForChild("BloodCaster"))
local Visualizer = require(Modules:WaitForChild("Visualizer"))
-- \\ VARIABLES // --
local CurrentCamera = workspace.CurrentCamera
local CameraOffset = Instance.new("CFrameValue")
local RecoilOffset = Instance.new("CFrameValue")
local CameraBoneOffset = Instance.new("CFrameValue")
local LocalPlayer = Players.LocalPlayer
local SplatSounds = Sounds:WaitForChild("Blood"):WaitForChild("Splat"):GetChildren()
local MeatSounds = Sounds:WaitForChild("Blood"):WaitForChild("Chunks"):GetChildren()
local Mouse = LocalPlayer:GetMouse()
local Mult = 60
local Current = Vector2.zero
local TargetX, TargetY = 0, 0
local SpeedX = 1000
local SpeedY = 1000
local SpeedZ = 250
local Sensitivity = 1
local RecoilModule = require(Modules.Spring).spring.new(Vector3.new())
RecoilModule.s = 5
RecoilModule.d = 0.8
_G.FOVs = {}
_G.WalkSpeeds = {}
-- \\ FUNCTIONS // --
local del = 0
local OldCamCF = nil
local function RenderStepped(Delta)
del = del + Delta
if del >= 1 / 60 then
del = del - 1 / 60
RecoilOffset.Value = CFrame.Angles(RecoilModule.p.x, RecoilModule.p.y, RecoilModule.p.z)
CurrentCamera.CFrame = CurrentCamera.CFrame * CameraOffset.Value * RecoilOffset.Value * CameraBoneOffset.Value
local FieldOfView = 0
for _, v in pairs(_G.FOVs) do
FieldOfView += v.Value
end
CurrentCamera.FieldOfView = 70 - FieldOfView
if LocalPlayer.Character then
if LocalPlayer.Character:FindFirstChildOfClass("Humanoid") then
local WS = 0
for _, v in pairs(_G.WalkSpeeds) do
WS += v.Value
end
-- TweenService:Create(LocalPlayer.Character.Humanoid, TweenInfo.new(1, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {WalkSpeed = (_G.SPR and 30 or _G.CR and 8 or 16) - WS}):Play()
-- TweenService:Create(LocalPlayer.Character.Humanoid, TweenInfo.new(1, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {HipHeight = _G.CR and -1.5 or 0}):Play()
if LocalPlayer.Character:FindFirstChild("CameraBone") then
local NewCamCF = LocalPlayer.Character.CameraBone.CFrame:ToObjectSpace(LocalPlayer.Character.HumanoidRootPart.CFrame)
if OldCamCF then
local _, _, Z = NewCamCF:ToOrientation()
local X, Y, _ = NewCamCF:ToObjectSpace(OldCamCF):ToEulerAnglesXYZ()
if (CurrentCamera.CFrame.Position - LocalPlayer.Character.Head.Position).Magnitude > 2 then
-- X, Y, Z = 0, 0, 0
end
CameraBoneOffset.Value = CameraBoneOffset.Value:Lerp(CFrame.Angles(X, Y, -Z), 0.1)
end
OldCamCF = NewCamCF
end
local Value = CFrame.new()
--[[
if LocalPlayer.Character.Humanoid.MoveDirection.Magnitude > 0 then
local t = tick()
local X = math.sin(t * 15) * 0.003
local Z = math.sin(t * 7.5) * 0.003
if _G.SPR then
X = math.sin(t * 20) * 0.0075
Z = math.sin(t * 10) * 0.0075
else
if _G.CR or _G.ADS then
X = math.sin(t * 6) * 0.001
Z = math.sin(t * 3) * 0.001
end
end
Value = CFrame.new(0, 0, 0) * CFrame.Angles(X, 0, Z)
end
]]
CameraOffset.Value = CameraOffset.Value:Lerp(Value, 0.1)
end
end
end
_G.SPR = (UserInputService:IsKeyDown(Enum.KeyCode.LeftShift) or UserInputService:IsKeyDown(Enum.KeyCode.RightShift))
_G.CR = not _G.SPR and (UserInputService:IsKeyDown(Enum.KeyCode.C) or UserInputService:IsKeyDown(Enum.KeyCode.RightControl) or UserInputService:IsKeyDown(Enum.KeyCode.C))
end
local Blood_Decals = {
176678070,
}
local function CreateBlood(Origin, Direction, Velocity, Amount, Tick)
Amount = Amount or 1
for i = 1, Amount do
local Drop = Effects:WaitForChild("Blood"):WaitForChild("Drop"):Clone()
if typeof(Origin) ~= "CFrame" then
Origin = Origin.CFrame
end
if not Direction then
Direction = Origin.LookVector + Vector3.new(math.random(-1000, 1000) / 10000, math.random(-1000, 1000) / 10000, math.random(-1000, 1000) / 10000)
end
Drop.CFrame = CFrame.new(Origin.Position, (Origin.Position + Direction))
Drop.Parent = BloodInstances
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Whitelist
raycastParams.FilterDescendantsInstances = { Workspace_:WaitForChild("Game"):WaitForChild("Map"), Workspace_.Terrain }
local Hitbox = BloodCaster.new(Drop)
Hitbox.DetectionMode = BloodCaster.DetectionMode.PartMode
Hitbox.Visualizer = false
Hitbox.RaycastParams = raycastParams
Hitbox:HitStart()
Drop.Velocity = Direction * Velocity
local function OnHit(A, B, C)
Drop:Destroy()
local Pool = Effects:WaitForChild("Blood"):WaitForChild("Pool"):Clone()
Pool.CFrame = CFrame.new(C.Position, C.Position - C.Normal) * CFrame.Angles(math.rad(90), math.rad(math.random(0, 180)), 0)
Pool.Parent = BloodInstances
Pool.Anchored = A.Anchored
Pool.Decal.Color3 = Color3.fromRGB(math.random(500, 1000) / 10, 0, 0)
Pool.Decal.Texture = "rbxassetid://"..Blood_Decals[math.random(1, #Blood_Decals)]
local Blood = ReplicatedStorage:WaitForChild("Effects"):WaitForChild("Blood"):WaitForChild("Blood"):Clone()
Blood.Parent = Pool
Blood:Emit(20)
local SplatSound = SplatSounds[math.random(1, #SplatSounds)]:Clone()
SplatSound.Parent = Pool
SplatSound.PlaybackSpeed = SplatSound.PlaybackSpeed + math.random(-100, 100) / 1000
SplatSound:Play()
if not Pool.Anchored then
local Weld = Instance.new("WeldConstraint", Pool)
Weld.Part0 = A
Weld.Part1 = Pool
end
Debris:AddItem(Pool, 10)
task.spawn(function()
task.wait(8)
TweenService:Create(Pool.Decal, TweenInfo.new(2), {Transparency = 1}):Play()
end)
end
Hitbox.OnHit:Connect(OnHit)
task.wait(Tick)
end
end
local function CreateChunk(Origin, Direction, Velocity, Amount, Tick)
Amount = Amount or 1
for i = 1, Amount do
local Meats = Effects:WaitForChild("Blood"):WaitForChild("Meats"):GetChildren()
local Drop = Meats[math.random(1, #Meats)]:Clone()
if typeof(Origin) ~= "CFrame" then
Origin = Origin.CFrame
end
if not Direction then
Direction = Origin.LookVector + Vector3.new(math.random(-1000, 1000) / 10000, math.random(-1000, 1000) / 10000, math.random(-1000, 1000) / 10000)
end
Drop.CFrame = CFrame.new(Origin.Position, (Origin.Position + Direction))
Drop.Parent = BloodInstances
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Whitelist
raycastParams.FilterDescendantsInstances = { Workspace_:WaitForChild("Game"):WaitForChild("Map"), Workspace_.Terrain }
local Hitbox = BloodCaster.new(Drop)
Hitbox.DetectionMode = BloodCaster.DetectionMode.PartMode
Hitbox.Visualizer = false
Hitbox.RaycastParams = raycastParams
Hitbox:HitStart()
Drop.Velocity = Direction * Velocity
local function OnHit(A, B, C)
TweenService:Create(Drop, TweenInfo.new(1, Enum.EasingStyle.Back, Enum.EasingDirection.Out), {Size = Vector3.new(Drop.Size.X + (math.random(1500, 2500) / 100000), Drop.Size.Y - (math.random(500, 1500) / 100000), Drop.Size.Z + (math.random(1500, 2500) / 100000))}):Play()
Drop.Anchored = true
Drop.CFrame = CFrame.new(C.Position, C.Position - C.Normal) * CFrame.Angles(math.rad(90), math.rad(math.random(0, 180)), 0)
Drop.Color = Color3.fromRGB(math.random(500, 1000) / 10, 33, 33)
local SplatSound = MeatSounds[math.random(1, #MeatSounds)]:Clone()
SplatSound.Parent = Drop
SplatSound.PlaybackSpeed = SplatSound.PlaybackSpeed + math.random(-100, 100) / 1000
SplatSound:Play()
local Blood = ReplicatedStorage:WaitForChild("Effects"):WaitForChild("Blood"):WaitForChild("Blood"):Clone()
Blood.Parent = Drop
Blood:Emit(20)
Debris:AddItem(Drop, 5)
task.spawn(function()
task.wait(3)
TweenService:Create(Drop, TweenInfo.new(2), {Transparency = 1}):Play()
TweenService:Create(Drop, TweenInfo.new(2), {Size = Vector3.new()}):Play()
end)
end
Hitbox.OnHit:Connect(OnHit)
task.wait(Tick)
end
end
local function InputBegan(Key, IsTyping)
if IsTyping then
return
end
end
local function Recoil(Recoil)
Recoil = Vector3.new(Recoil, math.random(-(Recoil * 350), (Recoil * 350)) / 1000, math.random(-(Recoil * 350), (Recoil * 350)) / 1000)
RecoilModule:Accelerate(Recoil)
task.spawn(function()
task.wait(0.03)
RecoilModule:Accelerate(-Recoil)
end)
end
local function ReloadEffects(Player, Tool, ...)
if Player then
if Player == LocalPlayer then
return
end
end
require(Tool.Modules.ReloadSounds)(...)
end
local function EquipEffects(Player, Tool, ...)
if Player then
if Player == LocalPlayer then
return
end
end
require(Tool.Modules.EquipSounds)(...)
end
local function MonitorExplosion(Explosion)
local Magnitude = (Explosion.Position - CurrentCamera.CFrame.Position).Magnitude
if Magnitude > 150 then
local Sounds = Explosion.Far:GetChildren()
local Sound = Sounds[math.random(1, #Sounds)]
Sound:Play()
elseif Magnitude <= 100 and Magnitude > 50 then
local Sounds = Explosion.Dist:GetChildren()
local Sound = Sounds[math.random(1, #Sounds)]
Sound:Play()
elseif Magnitude <= 50 then
local Sounds = Explosion.Near:GetChildren()
local Sound = Sounds[math.random(1, #Sounds)]
Sound:Play()
end
end
-- \\ COMMUNICATION // --
local Remotes = {
["RemoteFunction"] = Communication:FindFirstChildOfClass("RemoteFunction"),
["BindableEvent"] = Communication:FindFirstChildOfClass("BindableEvent"),
["RemoteEvent"] = Communication:FindFirstChildOfClass("RemoteEvent")
}
-- \\ MAIN // --
UserInputService.MouseIconEnabled = true
return function()
warn("|| LOADING GAME ||")
local LocalData
local LocalPlayer = Players.LocalPlayer
local Character = nil
LocalPlayer.CharacterAdded:Wait()
while true do
task.wait()
if game:IsLoaded() then
break
end
end
Character = LocalPlayer.Character
warn("|| LOADING FRAMEWORK ||")
LocalData = {
GameData = {
inLobby = false,
inGame = false
}
}
RunService.RenderStepped:Connect(RenderStepped)
UserInputService.InputBegan:Connect(InputBegan)
Remotes.RemoteEvent.OnClientEvent:Connect(function(f, ...)
if f == "CreateBlood" then
CreateBlood(...)
elseif f == "CreateChunk" then
CreateChunk(...)
elseif f == "Visualize" then
Visualizer(...)
elseif f == "Recoil" then
Recoil(...)
elseif f == "ReloadEffects" then
ReloadEffects(...)
elseif f == "EquipEffects" then
EquipEffects(...)
elseif f == "MonitorExplosion" then
MonitorExplosion(...)
end
end)
Remotes.BindableEvent.Event:Connect(function(f, ...)
if f == "CreateBlood" then
CreateBlood(...)
elseif f == "CreateChunk" then
CreateChunk(...)
elseif f == "Visualize" then
Visualizer(...)
elseif f == "Recoil" then
Recoil(...)
end
end)
local function changeState(IL_V, IG_V)
local GD = LocalData.GameData
if GD.inLobby ~= IL_V then
GD.inLobby = IL_V
elseif GD.inLobby == IL_V then
warn("Error: Tried setting Lobby value, got ".. IL_V .. " when value is already set to ".. GD.inLobby ..".")
end
if GD.inGame ~= IG_V then
GD.inGame = IG_V
elseif GD.inGame == IG_V then
warn("Error: Tried setting Game value, got ".. IG_V .. " when value is already set to ".. GD.inGame ..".")
end
end
_G.plrState = changeState
warn("|| GAME LOADED ||")
end
That’s all. Please help me understand or fix the problem of my gun system bug, to say the issue again, I can’t use two guns in one inventory or It’ll get buggy, actually, you can have many guns in one inventory as long as you only equip one of them. Meaning, if the ‘gunclient’ module gets required twice, it just bugs.