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

attempt to index a number value? help [FIxed]

Asked by 5 years ago
Edited 5 years ago

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

Log in to vote
0
Answered by
MuN8MuN 47
5 years ago

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

0
did't see the Typo kittensgaming123 19 — 5y
Ad

Answer this question