Help with making a player move, when they are disabled

Hello, I was working on my game today, and wasn’t able to figure out a simple thing. My goal is to have the player disabled and can’t move their character at the start of the game, but their character keeps on moving. Here is what I have so far, but all it is doing is making the player freeze, but not moving the player forward. (there are no errors.)

local player = game.Players.LocalPlayer
local playerscripts = player:FindFirstChild("PlayerScripts")
local players = game:GetService("Players")
local playerModule = require(playerscripts:WaitForChild("PlayerModule"))
local controls = playerModule:GetControls()
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local camera = workspace.CurrentCamera
local TweeningService = game:GetService("TweenService")

local moveSpeed = 20
local duration = 5

-- disable player control
controls:Disable()

-- move the player forward
humanoid.WalkSpeed = moveSpeed

-- wait for the specified duration
wait(duration)
humanoid.WalkSpeed = 16 -- reset to default walk speed
controls:Enable()

1 Like

You could try anchoring the player’s character’s HumanoidRootPart - They won’t move anywhere if it’s anchored.

1 Like

The part where the player can’t move isn’t a problem, I just need help with the player moving forward without doing anything. The player moving forward is completely controlled by the client for a specific duration.

1 Like

I guess you could try using Humanoid:Move() or Humanoid:MoveTo().

1 Like

So something like this?

local player = game.Players.LocalPlayer
local playerscripts = player:FindFirstChild("PlayerScripts")
local players = game:GetService("Players")
local playerModule = require(playerscripts:WaitForChild("PlayerModule"))
local controls = playerModule:GetControls()
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local camera = workspace.CurrentCamera
local TweeningService = game:GetService("TweenService")

local moveSpeed = 20
local duration = 5

-- disable player control
controls:Disable()

-- move the player forward
humanoid:MoveTo(workspace.THEpart)

-- wait for the specified duration
wait(duration)
humanoid.WalkSpeed = 16 -- reset to default walk speed
controls:Enable()

1 Like

Well, I’m not quite sure on what parameters MoveTo() takes, I’ve never used it before. Here is what Studio says about the parameters:
image

1 Like

Try creating a part (locally) that is transparent and position it to be around 100 studs from the player (more or less if you want) and make the player move to that part by using humanoid:MoveTo()

Yes, although what parameters are there in the function? I looked at the post above, and I don’t really understand.

The parameters are a specific location on a map (Vector3) or just a part (not a model).

Yes, I put a singular part, and it still doesn’t work.

Try using the part’s position instead of directly referencing it, would be

humanoid:MoveTo(workspace.THEpart.Position)

didn’t test though

You probably want to use the Move method for humanoids as you want it to move in a specific direction (not position, I assume). You can find more about how to use it here, with an overview here

-- assume variable A is a reference to a humanoid for the player
A:Move(direction_vector, relative_to_cam)

For some reason, it just gives me this error.

Try adding a 3 second wait at the beginning of the script (the part probably didn’t load in yet)

Thank you so much! I appreciate it!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.