So i made this scripts, that when the players hits a part, this gui starts appearing like the character is talking, but I want to make the character unable to walk (he can move the camera) while this script is running, how can I do that?
I guess you could anchor the character, that seems like the easiest way. If you want to be more fancy, you could use ContextActionService
to sink any inputs from the player so they effictively can’t move.
You can position the character how you want then set their humanoid’s WalkSpeed and JumpPower to 0.
This will disable the player’s movement, to enable them back just do the opposite: PlayerModule:Enable()
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local Module = player.PlayerScripts:FindFirstChild("PlayerModule") or player.PlayerScripts:WaitForChild("PlayerModule", 0.1)
local PlayerModule = require(Module)
local Controls = PlayerModule:GetControls()
Controls:Disable()
What I do is Anchor their HumanoidRootPart, or use a BodyPosition
Anchor their head or the humanoidrootpart. You can anchor any part of the character, but I prefer anchoring the head.
If using local script set the players WalkSpeed to 0 as shown below.
local player = game.Players.LocalPlayer
local character = player.Character
Character.humanoid.WalkSpeed = 0
I get weird behavior when anchoring/unanchoring the HumanoidRootPart of a player’s character. I would suggest setting the Humanoid’s Walkspeed to 0. Also remember to set the WalkSpeed back to 0 whenever the player dies. This is not an unhackable solution though (as are all localscripts), so I would suggest using a server-sided solution if it has to be exploit-proof.