Hi i am having a problem with my script here is my script:
local RS = game:GetService("ReplicatedStorage")
local PathFinding = require(script:WaitForChild("PathFinding"))
local Npc = RS:WaitForChild("SecurityGuard"):Clone()
local Npc2 = game.Workspace:WaitForChild("ClassD")
local Waypoints = workspace:WaitForChild("Waypoints")
Npc.Parent = workspace
task.wait(3)
local waypoint = math.random(1, #Waypoints:GetChildren())
PathFinding.MoveTo(Npc, waypoint.Position)
And i keep getting this like dumb error:
ServerScriptService.Script:15: attempt to index number with âPositionâ - Server - Script:15
BoogaRus
(IHateLua)
#2
Your waypoint is just a random number.
BoogaRus
(IHateLua)
#3
You should do something like this
local RS = game:GetService(âReplicatedStorageâ)
local PathFinding = require(script:WaitForChild(âPathFindingâ))
local Npc = RS:WaitForChild(âSecurityGuardâ):Clone()
local Npc2 = game.Workspace:WaitForChild(âClassDâ)
local Waypoints = workspace:WaitForChild(âWaypointsâ)
Npc.Parent = workspace
task.wait(3)
local WaypointsTable = Waypoints:GetChildren()
local Randomwaypoint = math.random(1, #WaypointsTable)
local waypoint = WaypointsTable[Randomwaypoint]
PathFinding.MoveTo(Npc, waypoint.Position)
1 Like
Front3D
(Front3D)
#5
local waypoint = Waypoints:GetChildren()[math.random(1, #Waypoints:GetChildren())]
1 Like