I'm making a dialog for an information booth in my game, the dialog's parent is a head of a character which has the standard character animations. But I want the character to be sort of glued to the ground so players can't mess up the characters position.
If I do script.Parent.HumanoidRootPart.Anchored = true
the animation breaks.
Has anyone fixed this before?
This works for me(local script)
local human = game.Players.LocalPlayer.Character local defaultWalk = human.WalkSpeed -- defines the walkspeed(how fast humanoid walks) local defaultJump = human.JumpPower -- defines the jumping power ( how much power to jump) human.WalkSpeed = 0 --prevents player from walking by setting the speed to 0 human.JumpPower = 0 -- prevents player from jumping by making jumppower to 0 human.PrimaryPart.Anchored = true -- this looks unnecessary as you already setted walk and jump to 0, but this is important so the thing wont move when it is pushed by other thing wait(5)--period of time for player being anchored human.WalkSpeed = defaultWalk human.JumpPower = defaultJump human.PrimaryPart.Anchored = false
if you want to access from normal script, add a new remoteevent named "freezePlayer" in replicatedStorage or wherever you want to go
--code --code --you come to point where you want to anchor the person local freezePlayer = game.ReplicatedStorage:WaitForChild("freezePlayer") -- defines the freezePlayer event inside Replicated Storage freezePlayer:FireAllClient() --fires the client(client is basically a player, so this is sending this event to all the client(Players)
then, add this to local script(store local script inside starterPlayer > starterplayerscript
local freezeMe = game.ReplicatedStorage:WaitForChild("freezePlayer") -- waiting for the event to load to prevent from game to define something that still does not exist. freezeMe.OnClientEvent:Connect(function() -- starts to run when the script( the one on above) fires the event local human = game.Players.LocalPlayer.Character local defaultWalk = human.WalkSpeed local defaultJump = human.JumpPower human.WalkSpeed = 0 human.JumpPower = 0 human.PrimaryPart.Anchored = true wait(5) human.WalkSpeed = defaultWalk human.JumpPower = defaultJump human.PrimaryPart.Anchored = false end)
I know that there is more faster ways to do it, but I am still a starter at scripting so sorry if these scripts is inefficient. Hope this works :D