Character won't move

What i’m doing is making the character move to the first green part when they touch the red part.
But the character isn’t moving.

https://gyazo.com/e72c257fdbc094b4c3fb7d90dfdfc6de

Normal script:

local Freeze = game.ReplicatedStorage:FindFirstChild("FreezePlayer")

local LineModel = script.Parent
local Spots = LineModel.Spots:GetChildren()

local Cooldown = false

local function spotCheck()	
	for SpotNumber = 1, #Spots, 1 do
		if not Spots[SpotNumber]:FindFirstChildOfClass("StringValue") then
			return Spots[SpotNumber]
		end
	end
end

LineModel.EnterPart.Touched:Connect(function(HitPart)
	if HitPart and HitPart.Parent:FindFirstChild("Humanoid") then
		if Cooldown == false then
			Cooldown = true
			local Character = HitPart.Parent
			local Player = game.Players:GetPlayerFromCharacter(Character)
			local Spot = spotCheck()
			
			spawn(function()
				wait(1)
				Cooldown = false
			end)	
			
			Freeze:FireClient(Player, true)
			Character:SetPrimaryPartCFrame(LineModel.TPPart.CFrame)
			Character.Humanoid:MoveTo(Spot.Position)
			Character.Humanoid.MoveToFinished:wait()
		end
	end
end)

Freeze script:

local ContextActionService = game:GetService("ContextActionService")
local FREEZE_ACTION = "freezeMovement"

game.ReplicatedStorage.FreezePlayer.OnClientEvent:Connect(function(State)
	if State == true then
		ContextActionService:BindAction(
			FREEZE_ACTION,
			function()
				return Enum.ContextActionResult.Sink -- need to explicitly return this
			end,
			false,
			unpack(Enum.PlayerActions:GetEnumItems())
		)
	elseif State == false then
		ContextActionService:UnbindAction(FREEZE_ACTION)
	end
end)

The line model:
image

Any help is appriciated!

The problem you’re experiencing here is that the client is the network owner of their character controller, not the server.

So the server is telling the Humanoid to move, but the Humanoid is actually being controlled by the Character.

To solve this, remove the :MoveTo call from the server, and move to to the client - something like this:

-- LocalScript (obviously)

local Players = game:GetService("Players")
local ContextActionService = game:GetService("ContextActionService")
local FREEZE_ACTION = "freezeMovement"
local Player = Players.LocalPlayer

local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")

game.ReplicatedStorage.FreezePlayer.OnClientEvent:Connect(function(State, TargetGoal)
	if State == true then
		ContextActionService:BindAction(
			FREEZE_ACTION,
			function()
				return Enum.ContextActionResult.Sink -- need to explicitly return this
			end,
			false,
			unpack(Enum.PlayerActions:GetEnumItems())
		)
                Humanoid:MoveTo(TargetGoal)
                Humanoid.MoveToFinished:Wait() -- I assume you want to unfreeze when they get there
                ContextActionService:UnbindAction(FREEZE_ACTION)
	elseif State == false then
		ContextActionService:UnbindAction(FREEZE_ACTION)
	end
end)

Sorry about the awful formatting

1 Like

So far, I’ve never experienced any issues with using :MoveTo() on the server, Why is it being weird now?

EDIT: It was working 10 minutes ago, Too.

1 Like

It would have worked in Studio most likely - or any instance where the character, for some reason, wasn’t the network owner of their client.

1 Like

The gif was also in studio, I don’t see how it’s client only.

Your character is controlled by the client entirely - even whilst the properties may not replicate their effects are the same. It would be stranger behavior for the Humanoid::MoveTo method call to work than not.

1 Like