I created a clickdetector that spawns a dummy which is suppose to move once it spawns. However, for some reason the script runs and prints “Lets move” and “Moving” but the dummy doesn’t actually move. Later in the script there is a function for the dummy to walk to another spot and when I run that function it works properly. So now I’m left wondering why the code works properly but the dummy doesn’t want to follow to first command to walk to PointA. Does anyone know the problem? Does it have anything to do with me having to insert a waitforchild?
local dummy = script.Parent
local humanoid = dummy.Humanoid
local pointA = game.Workspace.GreenFlag
local pointB = game.Workspace.PurpleFlag
local pointC = game.Workspace.YellowFlag
if game.Workspace.Customer1 ~= nil then
print("Lets move")
humanoid:MoveTo(pointA.PrimaryPart.Position)
print("Moving")
end
Update:
I changed up the code a bit and the dummy decided to take 2 steps and then stop.
local found = game.Workspace:WaitForChild("Customer1")
if found ~= nil then
print("Lets move")
humanoid:MoveTo(pointA.PrimaryPart.Position)
print("Moving")
end
Did you unanchor the dummy’s HumanoidRootPart? It might be stuck because the HumanoidRootPart of the dummy is anchored, have you also set the PrimaryPart of the model?
Try checking these things out and try again and let me know if any of these 2 fix your problem.
I set the “found” variable so that once the variable doesn’t equal nil it runs the command. I was working with other scripts and when I wrote “if found == true then” it didn’t work properly because the output wasn’t true. I’m new so it might not apply in this scenario but I just write not equal to nil to be safe.
But you haven’t explained to us what Customer1 is.
If the model Customer1 is spawned in the Workspace, but the Humanoid isn’t there, then it’s going to break the script.