You can write your topic however you want, but you need to answer these questions:
-
I Want to make the bot attack one Target at a time.
-
When the Remote event fire more than one time it Start attack more than one target.
The bot is a pet and This is a part of the script of the bot.
local function Attack(Target)
if FunctionRunning then return end
FunctionRunning = true
repeat
wait(0.5)
print(Target)
NoobModule:Attack(Character, Target)
until Attacking ~= true or Following == true or Target.Humanoid.Health == 0 or FunctionRunning == false
FunctionRunning = false
end
game.ReplicatedStorage["Remote events."]["Attack resever."].OnServerEvent:Connect(function(Player, Target, PlayerName)
if Character["Main Pet."].Value == false and PlayerName == Owner then
print("Message reseved.")
print(Target.PrimaryPart)
Character:SetAttribute("Attacking", true)
Character:SetAttribute("Following", false)
print(FunctionRunning)
Character:SetAttribute("Target", Target.Name)
Attack(Target)
Character:GetAttribute("Attacking", false)
FollowPlayer()
end
end)