Dummy not moving on spawn

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.

2 Likes

Yes, the dummy is unanchored because later in the script it makes the dummy move. The primaryparts are also set properly.

1 Like

Your WaitForChild is for Customer1, shouldn’t it be for the Humanoid?

1 Like

Unless I am mistaken, I am waiting on the model “Customer1” to be spawned in workspace before the function runs.

1 Like

Could you explain in detail what is “found” exactly?

Because you made it so the dummy can only move if “found” is not equal to nil and “found” might be equal to nil later on in the game for some reason.

1 Like

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.

1 Like

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.

1 Like

Oops my bad. The script I’m showing you is inside a dummy that is named “Customer1”.

My main issue is that the script runs fine since it prints the correct words but the dummy doesn’t move.

1 Like

Nvm, I realized the issue was that it ran the first function before it even spawned somehow. I fixed it by adding a wait(2)

1 Like