NOTE: I am sorry if its too long. I tried to make it nice and neat as much as I could.
I have 4 guns. Each one has a reloading animation.
When I reload one of the guns, it would play the animation of my second tool.
If I reload 2 SMG's, both mags will appear when only one has to appear since I reload one gun.
Local Script: Each tool has this same local script.
local shootEvent = script.Parent:WaitForChild("Remotes").Shoot
local reloadEvent = script.Parent:WaitForChild("Remotes").Reload
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local s = require(script.Parent.Module)
local uis = game:GetService("UserInputService")
local anims = script.Parent:WaitForChild("Animations")
local idleanim = hum:LoadAnimation(anims.Idle)
script.Parent.Equipped:Connect(function(mouse)
idleanim:Play()
shootFunction = mouse.Button1Down:Connect(function()
shootEvent:FireServer()
wait(0.1)
end)
end)
script.Parent.Unequipped:Connect(function()
idleanim:Stop()
shootFunction:Disconnect()
end)
uis.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.R then
reloadEvent:FireServer()
end
end)
Server Script: Each tool has a slighly different script. Example:
local shootEvent = script.Parent:WaitForChild("Remotes").Shoot
local reloadEvent = script.Parent:WaitForChild("Remotes").Reload
local anims = script.Parent:WaitForChild("Animations")
local sounds = script.Parent:WaitForChild("SoundsFolder")
canShoot = true
function shoot_gun(plr)
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local shootanim = hum:LoadAnimation(anims.Shoot)
--Shoot
if s.ammo > 0 and canShoot == true then
shootanim:Play()
sounds.Fire:Play()
shootanim:Stop()
end
end
function reload_gun(plr)
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:FindFirstChild("Humanoid")
local reloadanim = hum:LoadAnimation(anims.Reload)
canShoot = false
reloadanim:Play()
wait(1.5)
reloadanim:Stop()
canShoot = true
end
shootEvent.OnServerEvent:Connect(function(plr)
shoot_gun(plr)
end)
reloadEvent.OnServerEvent:Connect(function(plr)
reload_gun(plr)
end)
Videos of the issue:
Gewehr43 and STG44- The animations are getting very messy and you can see both mags fall down when I reload only one of the tools. video
M1 Garand and Thompson- The M1 Garand plays the animation of the Thompson when it shouldnt. Also, the Thompson is alright for some reason and the M1 Garand isnt disturbing it. video
M1 Garand- This is just to show you how the M1 Garand SHOULD work. video

1 comment
pls use text for links