Hey, im making GUI in my studio and i added an textbox and textbutton to the GUI. Im trying to make it so when i put a players name in the "textbox" and press the "textbutton" i would anchor the HEAD and not whole BODY. (im a beginner at scripting and sorry for bad english)
TButton.MouseButton1Click:connect(function() local text_1 = AnchorP1.Text; local Player_1 = game:GetService('Players'):FindFirstChild(text_1); if Player_1 then local char=Player_1.Character; local gd_1=char:GetDescendants(); for _,v in pairs(gd_1)do if v:IsA('BasePart')then v.Anchored=true; end; end; end; end)
Here you go. Cleaned it up a bit for you.
All that happened is you forgot to do some stuff in the script.
TButton.MouseButton1Click:Connect(function() local plrText = AnchorP1 local player = game:GetService("Players"):FindFirstChild(plrText.Text) if player then local char = player.Character or player.CharacterAdded:Wait() if char then for _,part in pairs(char:GetChildren()) do if part.Name == "Head" then part.Anchored = true end end end end end)