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

1 comment

0

research pathfinding, make sure you get the closest player using magnitude