Anchor script only working once

I have a part in my game that, when clicked, opens a GUI and anchors the player’s torso. Then, when you click a TextButton in the GUI’s frame, it unanchors the torso. These scripts work fine on the first try, but when I try them again, the player does not get anchored.

Line Of Code:
click.Character.UpperTorso.Anchored = true

click refers to the player who clicked using a function.

Is there a way to fix this?

Can you change that anchor target to HumanordRootPart?

Ok so I believe I had something similar to this. I just made a custom collision group, anywaysss, I believe anchoring may also work like the issue I was expierenicing with collision. But you could probally try a loop for example:

local is = true

TEXTBUTTON.mousebutton1click:Connect(function()
repeat
click.Character.UpperTorso.Anchored = true
until is = false
end)

I tried to use both your and @AceBookMarker’s solutions and created this:

repeat
	wait()
	click.Character.HumanoidRootPart.Anchored = true
	until Gui.Frame == nil
-- Gui gets destroyed when the TextButton is clicked, therefore making it nil.

Yet I still face the same issue where the script only anchors the player once.

Check what property is pointing to UpperTorso, or HumanordRootPart in character.

Use that property instead.

What do you mean by “pointing to?”

…This is answer.

player.Character.PrimaryPart

put lowertorso and uppertorso too

Try HumanoidRootPart. What I understand is you are trying to anchor the player itself.

New Post

I still seem to be facing the same problem, reworking the way the GUI is used and the anchoring with the provided solutions.