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

Workspace.Dummy.Controller:49: Incomplete statement: expected assignment or a function call?

Asked by 3 years ago

local hum = script.Parent:WaitForChild("Humanoid") local root = script.Parent:WaitForChild("HumanoidRootPart") local spawnpos = script.Parent:WaitForChild("SpawnPosition")

local visionrange = 99999 local attackrange = 3 local abandonrange = 999 local abandonrangefromhome = 999

local target = nil

while wait(1) do

if target then

    local plrRoot = target.HumanoidRootPart
    local distance = (root.Position - plrRoot.Position).magnitude
    local distancefromhome = (spawnpos.value - plrRoot.Position).magnitude

    hum:MoveTo(plrRoot.Position - CFrame.new(root.Position, plrRoot.Position).LookVector * attackrange)

    if distance <= attackrange + 2 then
        script.AttackRemote:fire(plrRoot)
    end

    if distance > abandonrange then
        print("abandoning target")
        target = nil
        hum:MoveTo(spawnpos.value)
    end

    if distancefromhome > abandonrangefromhome then
        print("abandoning target")
        target = nil
        hum:moveto(spawnpos.value)
    end

else

    for i,v in pairs(game.Players:GetChildren()) do

        if not game.Workspace:FindFirstChild(v.name) then continue end
        local char = game.Workspace[v.name]
        local plrRoot = char.HumanoidRootPart

        local distance = (root.Position - plrRoot.Position).magnitude
        local distancefromhome = (spawnpos.value - plrRoot.Position).magnitude

        if distance < visionrange and distancefromhome then distancefromhome < abandonrangefromhome then
            print("targeting"..v.name)
            target = char
        end

    end

end

end

1
You have 2 then. Replace the first one with and JustinWe12 723 — 3y
0
^On line 36 appxritixn 2235 — 3y

Answer this question