Check to see if the radius exists and is actually being touched by the zombie. Try changing
(hit.Parent.Name == "Minigunner")
to be able to detect the zombie since it looks for the minigunner instead.
Check to see if the radius exists and is actually being touched by the zombie. Try changing
(hit.Parent.Name == "Minigunner")
to be able to detect the zombie since it looks for the minigunner instead.
when I play test it, the radius is there and the zombies collide with it
Ah, so my assumption is that the script may be trying to check if the names of the zombies are "Minigunner"s. If itās not, then it wonāt execute the rest.
You can either rename the zombies to āMinigunnerā or change the āMinigunnerā part to āZombieā or whatever names you put for the zombies.
This script is in the zombie model
FastZombie = script.Parent
local TestEvent = game.ReplicatedStorage.Events.TestEvent
function onTouched(hit)
if (hit.Parent.Name == "Minigunner") then
print('touched minigun radius')
local NameValue = Instance.new("StringValue", game.Workspace.Minigunner.Stats)
NameValue.Name = 'ClosestEnemy'
NameValue.Value = FastZombie.Torso.Orientation
TestEvent:Fire()
end
end
connection = FastZombie.HumanoidRootPart.Touched:connect(onTouched)
Interesting, so you want the minigunners to touch the radius thatās in the zombie model in order for them to look at them?
Iām kind of stumped here since I canāt seem to figure out if itās the naming thatās causing the issue.
I was trying to get the minigunners to look at the zombies when they touch the radius
Hmmā¦
In the output, did it print ātouched minigun radiusā?
no, it did not print that (30 characters)
ah, that means that the NPC that is touching the radius isnāt named āMinigunnerā and wonāt run. Setting the names of the minigunners to āMinigunnerā might be able to run the rest of the script.
the minigunners were always named Minigunner
What about this line? Is the HumanoidRootPart the radius? What about āMinigunRadiusā? This makes it that it has to be touching the torso rather than the radius.
I changed it to
connection = FastZombie["Left Leg"].Touched:connect(onTouched)
and now Iām getting the error 16:35:08.141 - Workspace.Fast Zombie.Script:8: bad argument #3 (string expected, got Vector3)
Hey! Weāre getting thereā¦
Now for this bit
local NameValue = Instance.new("ObjectValue", game.Workspace.Minigunner.Stats)
NameValue.Name = 'ClosestEnemy'
NameValue.Value = FastZombie.Torso
Make the changes right where it says NameValue
, this uses the ObjectValue
instead of the StringValue
, so that way, the other script can actually see that part and get the position of it.
Darn.
Where is FastZombie referring to?
fast zombie is the name of the zombie
is there is a chance ur npc is R15 and thats why there is no torso?
every npc is r6 and has a torso
So FastZombie and ClosestEnemy are not Folders?
What about here? I forgot if FastZombie
was supposed to be there instead of script.Parent.Parent
.
fastzombie is the zombie, and closest enemy is a value inside of a folder