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

attempt to index a number value? help [FIxed]

I was making a script and on line 6 it all ways gives the error attempt to index a number value

local PathfindingService = game:GetService("PathfindingService")
local char = script.Parent
local Humanoid = char.Humanoid
while true do
	local path = PathfindingService:CreatePath()
    path:ComputeAsync(char.HumanoidRootPart.Position, Vector3.new(char.PrimaryPart.Position.X + math.random(-10,10),char.PrimaryPart.Position.Y + math.random(-10,10),char.PrimaryPart.Position.X + math.random(-10,10).Z)) -- the errors here
	path.Blocked:Connect(function()
		path:ComputeAsync(char.HumanoidRootPart.Position, Vector3.new(char.PrimaryPart.Position.X + math.random(-10,10),char.PrimaryPart.Position.Y + math.random(-10,10),char.PrimaryPart.Position.X + math.random(-10,10).Z))
	end)
	local waypoints = path:GetWaypoints()
	for _, waypoint in pairs(waypoints) do
		char:MoveTo(waypoint.Position)
		Humanoid.MoveToFinished:Wait()
	end
	wait(1)
end

1 answer

✓ Accepted answer

I'm not sure about that specific error, but char.PrimaryPart.Position.X + math.random(-10,10).Z looks strange. Math.random doesn't have a Z property

1 comment

0

did't see the Typo

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