Hey all! I’ve been developing on a game for a while now. Now I’m on the animation part, but for some reason the animation doesn’t play. And when I try to shoot now, it doesn’t shoot but it does add the bullet into the ‘Ignore’ folder in workspace.
Module (for 1 weapon)
local Settings = {
--// Types
WeaponType = "Automatic";
Range = 700;
FireRate = 650;
Damage = math.random(10, 25);
HeadDamage = math.random(30, 50);
--// Objects
Bullet = game:GetService("ReplicatedStorage"):WaitForChild("Bullets"):WaitForChild("P90_Bullet");
--// Animations
ShootingAnimation = "rbxassetid://7506963692";
IdleAnimation = "rbxassetid://7515970037";
}
return Settings
Client
local function SendBackToMenu()
for _, v in pairs(Weapons:GetChildren()) do
if character:FindFirstChild(v.Name) then
DisconnectWeaponRE:FireServer(character:FindFirstChild(v.Name))
end
end
end
local function NilCheckForWeapon(Weapon)
if Weapons:FindFirstChild(Weapon) then
FoundWeapon = Weapons:FindFirstChild(Weapon)
else
return
end
if Weapon_Settings:FindFirstChild(Weapon) then
FoundWeaponSettings = require(Weapon_Settings:FindFirstChild(Weapon))
else
return
end
end
NilCheckForWeapon("P90")
local function AddBullet(Weapon)
if (FoundWeapon and FoundWeaponSettings) == nil then
return
else
if not Shooting then
Shooting = true
local Muzzle = FoundWeapon:FindFirstChild("Muzzle")
local RayFromMuzzleToMousePosition = Ray.new(Muzzle.CFrame.Position, (mouse.Hit.Position - Muzzle.CFrame.Position).Unit * FoundWeaponSettings.Range)
local Hit, Position = workspace:FindPartOnRayWithIgnoreList(RayFromMuzzleToMousePosition, {character})
if Hit then
if Hit.Parent:FindFirstChild("Humanoid") then
if Hit.Name == "Head" then
Damage = FoundWeaponSettings.HeadDamage
else
Damage = FoundWeaponSettings.Damage
end
end
ShootRE:FireServer(Hit, Position, Damage, FoundWeaponSettings.Bullet)
end
task.wait(60 / FoundWeaponSettings["FireRate"])
Shooting = false
end
end
end
mouse.Button1Down:Connect(function()
MouseButton1Down = true
if (FoundWeapon and FoundWeaponSettings) == nil then
return
else
if FoundWeaponSettings.WeaponType == Automatic then
task.delay(0, function()
while MouseButton1Down do
if Shooting then
break
end
AddBullet("P90")
local ShootingAnim = Instance.new("Animation")
ShootingAnim.AnimationId = FoundWeaponSettings["ShootingAnimation"]
local LoadedShootingAnim = Animator:LoadAnimation(ShootingAnim)
LoadedShootingAnim:Play()
end
end)
end
end
end)
mouse.Button1Up:Connect(function()
MouseButton1Down = false
end)
SendClientCameraInfoRE.OnClientEvent:Connect(function()
ActivateTransition(function()
ThirdPersonCameraConnection = _Camera:ActivateThirdPerson()
end)
Deploy()
if FoundWeapon and FoundWeaponSettings ~= nil then
ConnectWeaponRE:FireServer(FoundWeapon, FoundWeaponSettings)
end
end)
ServerRemotes
ShootRE.OnServerEvent:Connect(function(player, hit, pos, damage, bullet)
if hit.Parent:FindFirstChild("Humanoid") then
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid.Health > 0 then
humanoid:TakeDamage(damage)
end
else
local BulletClone = bullet:Clone()
BulletClone.Position = pos
BulletClone.Anchored = true
BulletClone.CanCollide = false
BulletClone.Parent = workspace:FindFirstChild("Ignore")
game.Debris:AddItem(BulletClone, 5)
end
end)
ConnectWeaponRE.OnServerEvent:Connect(function(Player, FoundWeapon, FoundWeaponSettings)
local Character = Player.Character or Player.CharacterAdded:Wait()
-- Weapon Customizing
local WeaponClone = FoundWeapon:Clone()
for _, v in pairs(WeaponClone:GetDescendants()) do
if v:IsA("BasePart") then
v.Anchored = false;
v.CanCollide = false;
end
end
if not WeaponClone:FindFirstChild("WeaponGrip") then
local NewM6D = Instance.new("Motor6D")
NewM6D.Name = "WeaponGrip"
NewM6D.Parent = WeaponClone
NewM6D.Part1 = Character:FindFirstChild("UpperTorso")
NewM6D.Part0 = WeaponClone:FindFirstChild("BodyAttach")
else
local WeaponGrip = WeaponClone:FindFirstChild("WeaponGrip")
WeaponGrip.Part1 = Character:FindFirstChild("UpperTorso")
WeaponGrip.Part0 = WeaponClone:FindFirstChild("BodyAttach")
end
WeaponClone.Parent = Character
end)
DisconnectWeaponRE.OnServerEvent:Connect(function(Player, Weapon)
Weapon:Destroy()
end)
For extra info, here’s the gun in ReplicatedStorage:




