Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I make a function be able to find the target?

Asked by 2 years ago

I'm not sure how I can explain this but I'm pretty new to using module scripts and making my own functions. I'm currently making a turn based RPG and I need to make it so when I put the enemies' name in the function like "Dummy2" or reference said target then the function will attack that target. How can I do so? Here is the script:

local module = {}

Fighters = game.Workspace.Fighters
Points = game.Workspace.Points


function AttackA(targetName)
    local target = Fighters.Enemy:WaitForChild(targetName)
    local attacker = Fighters.Ally:WaitForChild("Dummy1")
    attacker.Humanoid:MoveTo(Points.AttackPoint.Position)

end

return module

0
research pathfinding, make sure you get the closest player using magnitude greatneil80 2647 — 2y

Answer this question