You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I am making a game with npcs that have a hitbox with a set damage and rate. -
What is the issue? Include screenshots / videos if possible!
The issue is that since i’m using the touched event, they only manage to land 2 or 3 hits, 5 max, and also, there is a delay when a few more npcs than usual are in the game, so sometimes the enemies will just group up in one spot and wait 10 seconds for everyone to attack at the same time. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve been thinking of recycling my turret system, because it attacks consistently and was also used as a replacement because I was going to make a tower defense game with touched events, but I don’t know if it’ll be the right thing, or if it will fit correctly.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
Here’s a script from one of the ally hitboxes.
local debounce = false
local dances = {script.Animation1,script.Animation2}
local Humanoid = script.Parent.Parent:WaitForChild('NPC')
local stabs = {script.Parent.Hit,script.Parent.Hit2,script.Parent.Hit3}
function onTouched(hit)
local human = hit.Parent:findFirstChild("Enemy")
if (human ~= nil) and human.Health>0 then
if not debounce then
debounce = true
local dance = Humanoid:LoadAnimation(dances[math.random(#dances)])
dance:Play()
Humanoid.WalkSpeed = 0
wait(0.5)
human.Health = human.Health - 10
stabs[math.random(#stabs)]:Play()
Humanoid.WalkSpeed = 16
wait(0.5)
debounce = false
end
end
end
script.Parent.Touched:connect(onTouched)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.