Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I fix the zombie? also how can I add It so the zombie damages other players, but not you?

Asked by 2 years ago

Im making a zombie staff that summons a zombie that acts like a guard dog, the zombie will attack other players besides you, anyway the problem Is where the zombie won't move, the output says:

Argument 2 missing or nil

I was wondering why, also I was wondering how can I modify the script so It damages other players besides you

Also there Is a StringValue In the zombie, the reason why It Is there Is because of the spawning script which can be found below the pathfinding

PathFinding:

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()

    path:ComputeAsync(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

Summon 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
Give us the line where the error appears, should be before the error message between the script path and error message ryanzhzh 128 — 2y
0
Line 30 In pathfinding imnotaguest1121 362 — 2y

2 answers

Log in to vote
0
Answered by
ryanzhzh 128
2 years ago
Edited 2 years ago

Too hard. Always got it not working. ------- OLD POST --------------- First fix Line 30 to this:

-- Lines before Line 30
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

I'm really confused!

0
I'll answer question 2 later ryanzhzh 128 — 2y
Ad
Log in to vote
0
Answered by
enes223 327 Moderation Voter
2 years ago

hey you! have you ever heard of enes? if you are in trouble, better call enes!

Answer this question