Hey There I’m making a game on Roblox that revolves around these types of magics called Arts and an important factor of the game is making these “Arts” as efficient as possible.
An important aspect that I want to implement is a projectile only hitting a player or NPC once.
As you know with the . Touched Function if a player gets hit by the projectile it will rapidly say that it hits the player and cause the Touched function to run multiple times which is good in some cases but for my case, it’s not that great. In the meanwhile what I have been doing to combat this is using a tag system where I create a bool value on the first hit of the projectile and have the projectile check if the tag exists before applying the effects of the art but I’m wondering if there is a better way to do this
local Projectile = game.ReplicatedStorage.DarkMagic.DarkSpike:Clone()
Projectile.Touched:Connect(function(Hit)
if Hit:FindFirstChild("Humanoid") and Hit:FindFirstChild("Tag_"..plr.UserId) == nil then
local Tag = Instance.new("BoolValue")
Tag.Name = "Tag_"..plr.UserId
Tag.Parent = Hit.Parent
--Where i would implement art logic
end
end)
Feel free to let me know!
Thank you!