When the pet is near a NPC it fires “Start” , if the pet is released it fires “Release”. Is there a better/more efficient way to write this?
local PetInfo = {}
game.ReplicatedStorage.CombatRemote.OnServerEvent:Connect(function(plr,petNum,arg,Target)
local Pet = GlobalF:GetPetFromNum(plr,petNum)
if arg == "Start" then
PetInfo[Pet] = {CurrentCombo = 0}
Combat(Pet)
elseif arg == "Release" then
PetInfo[Pet] = nil
end
end)
function Combat(Pet)
if PetInfo[Pet] then
local Data = PetData[Pet.SourceName.Value]
if PetInfo[Pet].CurrentCombo < Data.HitsBeforeUlt then
PetInfo[Pet].CurrentCombo += 1
print(PetInfo[Pet].CurrentCombo)
wait(1)
Combat(Pet)
else
Ultimate(Pet)
end
end
end
function Ultimate(Pet)
local Data = PetData[Pet.SourceName.Value]
print("ULTIII",PetInfo[Pet].CurrentCombo)
wait(5)
PetInfo[Pet].CurrentCombo = 0
Combat(Pet)
end