Basically had a situation similar to this in
but ya know, the post died so im checking if i can shorten a different part of the code thats similarly structured like the other one
Anyways any clue how to shorten this
local function reload()
if reloading then return end
reloading = true
if StoredAmmo.Value <= 0 then
print("Out Of Ammo")
reloading = false
tool.Folder.Magazine.ak47_magin:Play()
return
end
if game.ReplicatedStorage.Tals:FindFirstChild(gt.Value).ReloadTals:FindFirstChild(tool.strings.T1.Value) then
local TalFolder = game:GetService("ReplicatedStorage").Tals
local TalentMod = require(TalFolder:FindFirstChild(gt.Value).ReloadTals:WaitForChild(tool.strings.T1.Value))
local strings = tool.strings
TalentMod.Yes(strings, "T1")
elseif game.ReplicatedStorage.Tals:FindFirstChild(gt.Value).ReloadTals:FindFirstChild(tool.strings.T2.Value) then
local TalFolder = game:GetService("ReplicatedStorage").Tals
local TalentMod = require(TalFolder:FindFirstChild(gt.Value).ReloadTals:WaitForChild(tool.strings.T2.Value))
local strings = tool.strings
TalentMod.Yes(strings, "T2")
elseif game.ReplicatedStorage.Tals:FindFirstChild(gt.Value).ReloadTals:FindFirstChild(tool.strings.T3.Value) then
local TalFolder = game:GetService("ReplicatedStorage").Tals
local TalentMod = require(TalFolder:FindFirstChild(gt.Value).ReloadTals:WaitForChild(tool.strings.T3.Value))
local strings = tool.strings
TalentMod.Yes(strings, "T3")
elseif game.ReplicatedStorage.Tals:FindFirstChild(gt.Value).ReloadTals:FindFirstChild(tool.strings.T4.Value) then
local TalFolder = game:GetService("ReplicatedStorage").Tals
local TalentMod = require(TalFolder:FindFirstChild(gt.Value).ReloadTals:WaitForChild(tool.strings.T4.Value))
local strings = tool.strings
TalentMod.Yes(strings, "T4")
else
local reloadsound = tool.Sounds["AK47-RELOAD"]
local rsound = reloadsound:Clone()
rsound.Parent = tool.Folder.Magazine
rsound:Play()
wait(2.664)
if StoredAmmo.Value >= 30 then
local NeededAmmo = 30 - AmmoLeft.Value
StoredAmmo.Value -= NeededAmmo
AmmoLeft.Value += NeededAmmo
reloading = false
else
local NeededAmmo = 30 - AmmoLeft.Value
if NeededAmmo > StoredAmmo.Value then
AmmoLeft.Value += StoredAmmo.Value
StoredAmmo.Value = 0
reloading = false
end
end
rsound:Destroy()
end
reloading = false
end
(mainly the elseif statements)