Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make character freeze until they close the gui?

My code so far for the gui:


local Screen = script.Parent.Screen
local ActivationButton = script.Parent.Parent.Screen["Play "]
local ExitButton = script.Parent.Screen.Exit
local Player = game.Players.LocalPlayer

ActivationButton.Activated:Connect(function()
	Screen.Visible = true
end)

ExitButton.Activated:Connect(function()
	Player.CameraMode = Enum.CameraMode.LockFirstPerson
	Screen.Visible = false
end)

I want to add a piece of code that makes the player unable to move until they have closed the Guiscreen but i'm not sure how to code it.

5 comments

0

Look into PlatformStand on the characters humanoid

0

you could also just anchor one of the characters body parts

0

Hey Jedi Y dont u answer with the answer tab? Y do u type In comments dont u want Rep?

0

just set Character.WalkSpeed to 0, then when they click the button, you set it back to whatever it was on

0

And the jump power to 0

3 answers

maybe you can anchor the player's Character and add code that unanchors it when the GUI is closed here's a sample

local Char = Player.Character
ActivationButton.Activated:Connect(function()
    Screen.Visible = true
    Char.Anchored = true
end)

ExitButton.Activated:Connect(function()
	    Player.CameraMode = Enum.CameraMode.LockFirstPerson
	    Screen.Visible = false
            Char.Anchored = false
end)

note: I didn't add the whole code because I am lazy

2 comments

0

If this doesnt work only anchor the legs

0

Anchoring just causes latency problems, and sometimes it doesnt even work.

Hmmm...

Try this. I anchored my HumanoidRootPart in testing and my whole body couldn't move. If it doesn't tell me.

local Screen = script.Parent.Screen
local ActivationButton = script.Parent.Parent.Screen["Play "]
local ExitButton = script.Parent.Screen.Exit
local Player = game.Players.LocalPlayer

ActivationButton.Activated:Connect(function()
     Player.Character.HumanoidRootPart.Anchored = true
    Screen.Visible = true
end)

ExitButton.Activated:Connect(function()
    Player.Character.HumanoidRootPart.Anchored = false
    Player.CameraMode = Enum.CameraMode.LockFirstPerson
    Screen.Visible = false
end)

You can just set the Humanoid's WalkSpeed, JumpPower, and AutoRotate to 0 or false once they open the GUI, and set them back to default(16, 50 and true respectively) once they close it

This discussion is preserved as it was. New answers, comments, and votes are closed.