In my game i need an npc to destory a anchored object. For some reason this isnt working proper. The npc's sword fires the touched event once then it fires a random. Is there a way to fix this
Code:
Handle.Touched:Connect(function(Hit) -- This isnt firing when the npc touched a tycoon part
local Humanoid = Hit.Parent:FindFirstChild("Humanoid")
if Humanoid and not Hit.Parent.Parent.Name == "Troops" then
Humanoid:TakeDamage(script.Parent.Parent.TroopScripts.Damage.Value)
script.Parent.CanAttack.Value = false
end
local StringValue = Hit.Parent:FindFirstChild("PName")
if StringValue and string.find(Hit.Parent.Name, "Tycoon") and StringValue.Value ~= script.Parent.Parent.Name then
Hit.Parent.Health.Value -= (script.Parent.Parent.TroopScripts.Damage.Value)
script.Parent.CanAttack.Value = false
end
end)

2 comments
It fires a random what?
it fires randomly