Hi. I’m currently trying to script an AA12. The problem however is that configuration
somewhat shows up as nil
in the output therefore the rest of the script won’t run.
The Local Script:
local player = game.Players.LocalPlayer
local tool = script.Parent.Parent
local sounds = tool:FindFirstChild("Sounds")
local events = tool:FindFirstChild("Events")
local animations = tool:FindFirstChild("Animations")
local configuration = tool:FindFirstChild("Configuration")
local reloadTime = configuration.Reload
local fireRate = configuration.FireRate
local ammo = configuration.Ammo
local magazine = configuration.Magazine
local bulletValue = configuration.Bullet
local shells = configuration.Shell
local camera = workspace.CurrentCamera
local bulletValue = tool.Configuration.Bullet
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local shooting = events.Shoot
local reload = events.Reload
local handle = script.Parent.Parent.Handle
local mag = script.Parent.Parent.AA12.Magazine
local inputService = game:GetService("UserInputService")
local mouse = player:GetMouse()
local equipAnim = hum:LoadAnimation(animations.Equipped)
local shootingAnim = hum:LoadAnimation(animations.Shooting)
local reloadAnim = hum:LoadAnimation(animations.Reload)
local equipped = false
local firing = false
tool.Equipped:Connect(function()
equipped = true
equipAnim:Play()
end)
tool.Unequipped:Connect(function()
equipped = false
equipAnim:Stop()
shootingAnim:Stop()
reloadAnim:Stop()
end)
inputService.InputBegan:Connect(function(input)
if equipped then
if input.KeyCode == Enum.KeyCode.R then
if bulletValue.Value < 140 then
firing = false
reload:FireServer()
reloadAnim:Play()
end
end
end
end)
mouse.Button1Down:Connect(function()
if equipped and not firing then
firing = true
if bulletValue.Value > 0 then
while firing == true do
mouse.Button1Up:Connect(function()
firing = false
end)
mouse.TargetFilter = workspace.BulletStorage
shooting:FireServer(mouse.Hit.Position)
shootingAnim:Play()
task.wait(fireRate.Value)
end
end
end
end)
I also have a M4A1 with nearly the exact same script as well. For the M4A1, it works perfectly fine.
local player = game.Players.LocalPlayer
local tool = script.Parent.Parent
local sounds = tool:FindFirstChild("Sounds")
local events = tool:FindFirstChild("Events")
local animations = tool:FindFirstChild("Animations")
local configuration = tool:FindFirstChild("Configuration")
local reloadTime = configuration.Reload
local fireRate = configuration.FireRate
local ammo = configuration.Ammo
local magazine = configuration.Magazine
local bulletValue = configuration.Bullet
local camera = workspace.CurrentCamera
local bulletValue = tool.Configuration.Bullet
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local shooting = events.Shoot
local reload = events.Reload
local handle = script.Parent.Parent.Handle
local mag = script.Parent.Parent.M4A1.Mag
local inputService = game:GetService("UserInputService")
local mouse = player:GetMouse()
local equipAnim = hum:LoadAnimation(animations.Equipped)
local shootingAnim = hum:LoadAnimation(animations.Shooting)
local reloadAnim = hum:LoadAnimation(animations.Reload)
local equipped = false
local firing = false
tool.Equipped:Connect(function()
equipped = true
equipAnim:Play()
end)
tool.Unequipped:Connect(function()
equipped = false
equipAnim:Stop()
shootingAnim:Stop()
reloadAnim:Stop()
end)
inputService.InputBegan:Connect(function(input)
if equipped then
if input.KeyCode == Enum.KeyCode.R then
if bulletValue.Value < 30 then
firing = false
reload:FireServer()
reloadAnim:Play()
end
end
end
end)
mouse.Button1Down:Connect(function()
if equipped and not firing then
firing = true
if bulletValue.Value > 0 then
while firing == true do
mouse.Button1Up:Connect(function()
firing = false
end)
mouse.TargetFilter = workspace.BulletStorage
shooting:FireServer(mouse.Hit.Position)
shootingAnim:Play()
task.wait(fireRate.Value)
end
end
end
end)
Is there anyway to fix this issue?