Disable player movement

I have a quick text intro in my game and want all player interaction to stop/pause/wait/disable for 5 seconds while it happens, how do I do this?

I'm not 100% sure what you mean by player interaction.

If you want player movement to stop, you can do something like below.

If you have any key bindings you want to stop you just wait 5 seconds before connecting them or you could set up a table that checks if that player can press the key.

 --for these variable it's better to setup default globals somewhere else in code vs hard 
--coding them in like I'm doing but for this example hopefully it'll show you the basic 
--idea of stopping/resuming  movement

local DEFAULT_MAX_WALK_SPEED = 960
local DEFAULT_MAX_JUMP_COUNT = 1
local STOP_MOVEMENT_TIME_ON_JOIN = 5

function StopPlayerMovement(player)
player.maxWalkSpeed = 0
player.maxJumpCount = 0
end

function ResumePlayerMovement(player)
player.maxWalkSpeed = DEFAULT_MAX_WALK_SPEED
player.maxJumpCount = DEFAULT_MAX_JUMP_COUNT
end

function OnPlayerJoined(player)
StopPlayerMovement(player)
Task.Wait(STOP_MOVEMENT_TIME_ON_JOIN)
ResumePlayerMovement(player)
end

Game.playerJoinedEvent:Connect(OnPlayerJoined)
1 Like

That worked flawlessly! thank you! much love :heart:

1 Like