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

the error code is players is not a valid member of DataModel "Baseplate"?

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.potition - 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(spaenpos.value)
    end

    if distancefromhome > abandonranefromhome then
        print("abandoning target")
        target = nil
        hum:moveto(spaenpos.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.potition - plrRoot.position).magnitude
        local distancefromhome = (spawnpos.value - plrRoot.position).magnitude

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

    end

end

end

1 answer

Log in to vote
0
Answered by 3 years ago

When answering, if your answer does not fully solve the question, it should be written as a comment to the question instead of as an answer.

Its uppercase P for Players on line 27

0
that didnt seem to do it, thanks you tho. OpticsOnline 6 — 3y
0
??? JustinWe12 723 — 3y
Ad

Answer this question