Hello!
Im making a zombie staff that summons a zombie from ReplicatedStorage that targets other people besides you, currently, It does nothing
(Also, there Is a StringValue Inside of the zombie, Its used to get the owner of the zombie staff)
No errors appeared In
Script (Zombie):
local NPC = script.Parent
local Pathfinding = game:GetService("PathfindingService")
local Creator = script.Parent.Creator
function GetPlayerNames()
local players = game:GetService('Players'):GetChildren()
local name = nil
for _, v in pairs(players) do
if v:IsA'Player' then
name = tostring(v.Name)
end
end
return name
end
function GetTorso(part)
local chars = game.Workspace:GetChildren()
local torso = nil
for _, v in pairs(chars) do
if v:IsA'Model' and v ~= script.Parent and v.Name == GetPlayerNames() and not v.Name == Creator.Value then
local charRoot = v:FindFirstChild'HumanoidRootPart'
if (charRoot.Position - part).magnitude < SearchDistance then
torso = charRoot
end
end
end
return torso
end
while task.wait() do
local path = Pathfinding:CreatePath()
local NPC_Torso
if NPC:FindFirstChild("UpperTorso") then
NPC_Torso = NPC.UpperTorso
else
NPC_Torso = NPC.Torso
end
if GetTorso(NPC_Torso) == nil then
return
end
-- Line 30
path:ComputeAsync(GetTorso(NPC_Torso).Position, GetTorso(NPC_Torso).Position)--its gonna make a radius around the npc torso position to check for players
if path.Status == Enum.PathStatus.Success then
local Positions = path:GetWaypoints()
for i,v in pairs(Positions) do
local position = Instance.new("Part")
position.Parent = game.Workspace
position.Size = Vector3.new(1,1,1)
position.Position = v.Position
position.Transparency = 1
NPC.Humanoid:MoveTo(position.Position)
NPC.Humanoid.MoveToFinished:Wait(2)
position:Destroy()
end
end
end
Summoning script:
local tool = script.Parent
local debounce = false
tool.Activated:Connect(function()
if not debounce then
debounce = true
local Zombie = game.ReplicatedStorage.Zombie:Clone()
Zombie.Parent = game.Workspace
Zombie.Torso.CFrame = tool.Handle.CFrame
if Zombie:FindFirstChild("Creator") then
Zombie:FindFirstChild("Creator").Value = tool.Parent.Name --Tool > Character > Name
end
end
end)

1 comment
Congrats to people that actually read through it all!