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()
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.
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()
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()
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)