Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

Its uppercase P for Players on line 27

2 comments

0

that didnt seem to do it, thanks you tho.

0

???

This discussion is preserved as it was. New answers, comments, and votes are closed.