local move = {
["NPC Name"] = "NPC";
["Type"] = "Folder";
["Type Name"] = "MoveParts";
["Cooldown"] = "1";
["Repeat"] = "Use";
}
print(move)
local repeat_value = Instance.new("BoolValue", script)
repeat_value.Name = "IsRepeating"
repeat_value.Value = false
if move["Repeat"] == "Use" then
repeat_value.Value = true
else
repeat_value.Value = false
end
local npc = workspace:WaitForChild(move["NPC Name"])
local humanoid = npc:WaitForChild("Humanoid")
local moveparts
local moveparts_type
if move["Type"] == "Folder" then
moveparts_type = "Folder"
elseif move["Type"] == "Model" then
moveparts_type = "Model"
else
warn("There is no folder or model")
end
for work, parts in pairs(workspace:GetChildren()) do
if parts:IsA(moveparts_type) and parts.Name == move["Type Name"] then
for i,v in pairs(parts:GetChildren()) do
if v:IsA("Part") then
moveparts = v
end
end
end
end
local function loop()
while true do
task.wait(1)
if move["Repeat"] == "Use" and repeat_value.Value == false then
repeat_value = true
end
if move["Repeat"] == "NotUse" and repeat_value.Value == true then
repeat_value = false
end
end
end
spawn(loop)
local function Move()
while true do
if move["Repeat"] == "Use" and repeat_value.Value == true then
humanoid:MoveTo(moveparts.Position)
humanoid.MoveToFinished:Wait()
task.wait(move["Cooldown"])
end
end
for q,c in pairs(npc:GetChildren()) do
if c:IsA("Part") then
if c.Name == "HumanoidRootPart" then
if c.Anchored == true then
c.Anchored = false
end
end
end
end
function move.Start(use) -- error
print(use)
if use == true then
if move["Repeat"] == "Use" and repeat_value.Value == true then
spawn(move)
else
humanoid:MoveTo(moveparts.Position)
humanoid.MoveToFinished:Wait()
end
else
script:Destroy()
end
end
end
return move
umm no idea why this is happening, even I am getting similar error in my script when I pass an argument to a function in another module. The worse part is I still didn’t get the fix
local function Move()
...
end
function move.Start(use) -- error
...
end
end
You have move.Start() INSIDE of Move() (The local function). That’s why its giving you nil for the function, because it cant actually find it, since it’s inside another one.
Just move it outside and you should be fine.
Yes, but the move.Start function is inside of the Move() function, that’s what he’s trying to say, if you look at the end placements, you can see Move() doesn’t finish until the very bottom, before return move