Is there a way to move the player by the server without the player being able to move for that time?

So I have this script here:

game.Players.PlayerAdded:Connect(function(plr)
	local plrChar = plr.Character or plr.CharacterAdded:Wait()
	
	playerhum = plr.Character:WaitForChild("Humanoid")
end)

wait(8)

print("script started!")

playerhum.WalkSpeed = 0

playerhum:MoveTo(Vector3.new(28,0,28))

wait(2.5)

playerhum.WalkSpeed = 16

print("script ended")

And what that script does is to move the player to a specific location but the problem here is that the player can move while the script is still moving the player and that will stop the script from moving the player so how do I disable the player from moving while the script is moving the player?

I have tried to set the player’s walk speed to 0 so the player can’t move while the script is moving the player but that will also stop the script from working and when the player’s walk speed is back to 16 the script will work again.

So is there any way to fix this?

Could you not use CFrame to move the player?

So there would be a way to move the player through the server and making them not move for a set amount of time. which this would involve Remote Events, which would make the job easier since you can fire them through a local script, but here is the code I made for you. And to keep in mind this is a server script.


-- [[ DATA ]] --
local TeleportWalkspeed = 0
local NormalWalkspeed = 16

local Event = [[ Your event location ]]

-- [[ FUNCTIONS ]] --
function Teleport(Character, DestinationCFrame)
  if ( Character ) then
     Character.Humanoid.Walkspeed = TeleportWalkspeed

     wait(0.11) -- Delay

     Character.Humanoid:MoveTo(Vector3.new(DestinationCFrame))

     wait(0.11) -- Delay

     Character.Humanoid.Walkspeed = NormalWalkspeed
  end
end

-- [[ CONNECTIONS ]] --
Event.OnServerEvent:Connect(function(Arg1, Arg2)
   Teleport(Arg1, Arg2)
end)

Um also does move to not only work on models? Your trying to use it on the Humanoid?

image

I want to move the player to a specific location by the server and not teleport the player, the issue here is that the player can move while the server is moving the player and I wanted to know if there’s a way to prevent that.

This function is not available for a player since its a function only available to models.

1 Like

You could do this.

local Controller = require(game.Players.LocalPlayer:WaitForChild("PlayerScripts"):WaitForChild("PlayerModule")):GetControls()

Controller:Disable()

Controller:Enable()

Controller:Disable() will disable players controls while Controller:Enable() will enable them.

Yea that is what I said lol. …

Edited the code to your criteria, maybe try it since not it should use Humanoid:MoveTo().

It’s only available through the client, you need a Server-Client RemoteEvent. When a player joins, make the server fire to the client to disable their controls until the MoveTo finishes, then fire again to enable the controls

2 Likes

It can’t mean that because wait for child waits for the child for ever if it never does come (also called an infinity wait thinggg)