I am trying to disable and enable player's input so that they cannot move/jump. I am aware of setting JumpPower and WalkSpeed to 0, but the player is being moved via scripts. Player touches npc, triggers cut scene and disables controls.
RunService:UnbindFromRenderStep("ControlScriptRenderstep")
Player then battles npc and either wins or dies.
If it wins it will run the code,
RunService:BindToRenderStep("ControlScriptRenderstep", Enum.RenderPriority.Input.Value, function(dt) Controls:OnRenderStepped(dt) end)
and then the player can move again. However, when it dies it will run the same code, however the player cannot move. I have tried running an event right when the player's health is set to 0, I've tried
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character:WaitForChild("Humanoid").Died:Connect(function()
repeat wait() until player.Character
game.ReplicatedStorage.Remotes.CharDiedRemote:FireClient(player)
print("Died")
end)
end)
end)
and then in a local script
local function CharDied()
print("Respawned")
RunService:BindToRenderStep("ControlScriptRenderstep", Enum.RenderPriority.Input.Value, function(dt) Controls:OnRenderStepped(dt) end)
end
game.ReplicatedStorage.Remotes.CharDiedRemote.OnClientEvent:Connect(CharDied)
It prints both died and respawned, but still doesn't allow player to move.
Is there a better way of doing this, or am I doing something incorrectly?

3 comments
I've actually tried this as well, with the same result. It will enable controls if win, but not if the player dies.
I got it to work, I added in repeat wait() until player.Character:FindFirstChild("Head") before firing the remote, and it worked. Must have been trying to activate while they didn't exist or something.
WaitForChild is your best friend lol