I’m trying to make a tycoon game where you have npcs that fight for you and capture points on the map similar to clone tycoon and all those army games with the same concept but I can’t find any relevant resources on here and other platforms so I’m having trouble figuring out how to make it, I already know how to make a tycoon and enemy npcs but if anyone has resources related to other aspects of this kind of game like how to make an npc system that fights for the player and making points for the npcs to capture I’d appreciate if they were sent on here, thanks.
Hello Mysteryking10! I will be glad to aid you in finding the solution to your problem.
I actually had a similar game idea in the past, but got caught up in a rather different game project instead. From what I remember though, I watched this playlist. The videos inside should solve almost all of your issues with the NPCs, so I strongly recommend checking it out.
Watch this and this, inside the playlist I mentioned previously, to know exactly how to get your NPCs to the points, and in a singular script. You will have to do some tinkering, but I believe you can figure it out.
For the capturing system, though, I couldn’t find anything. But, it should be pretty easy to make a framework for it. It can go something like this:
First, create parts that are scaled and tuned to their respective point. These parts will be the range of which the NPCs can enter to claim the point.
Once you’re done adding all the parts, select them all. Make sure you set the CanCollide setting is off, the parts to anchored, and, if you prefer, the transparency to 1.
Then make a folder in the workspace, and rename it to “PointsFolder”.
After that, you should make a script in Replicated Storage and put the following code into it:
local pointsFolder = game.Workspace:WaitForChild(“PointsFolder”)
local points = {pointsFolder:GetChildren()}
local debounce = 30 -- This is the delay between two valid interactions. Change this later.
points.Touched:Connect(function(touchedPart, hit)
local humanoid = hit.Parent:FindFirstChild(“Humanoid”)
if humanoid then
if not touchedPart:GetAttribute(“Touched”) then
if hit.Parent:FindFirstChild(“Team”) then -- Checker for team. Change this later.
touchedPart:SetAttribute(“Touched”, true”)
--[[ You can either:
A. Fire a bindable event
B. Use a coroutine function
C. Run a function inside this script
If you choose C, remove debounce.
Whichever you choose, put it in here.
]]
task.wait(debounce)
touchedPart:SetAttribute(“Touched”, false”)
end
end
end
end)
Note: I wrote the code above on my iPhone, so I don’t know if it will work correctly or not. If you run into any issues, then please copy the output and reply it to me. I will try my best to fix it, and if you don’t hear from me again then try to find a different framework that might actually work better than mine.
I hope you have a great time with your game, and I wish upon you some good luck!