How to Anchor Players HumanoidRootPart

  1. I want to anchor the root part of the players character when they join.

  2. I can’t find out why it’s not Anchoring and it’s giving me no errors, so I’m just really confused on why it isn’t working.

  3. I’ve tried to switch it from a local script into one of my server scripts, but it still didn’t work.

I just started scripting, and it would really mean a lot if I could get some help, and know what I should do next time, Thanks!

local RS = game:GetService("ReplicatedStorage")
local plr = game:GetService("Players")
local Weld = RS.IdleWeaponWeld
local Sword = RS.Sword

plr.PlayerAdded:Connect(function(plr)
	
	plr.CharacterAdded:Connect(function(char)
		
		Weld.Parent = char.Torso
		Weld.Part0 = char.Torso
		Weld.Part1 = Sword
		Sword.Parent = char
		char:WaitForChild("HumanoidRootPart").Anchored = true
		
		if game.StarterGui.StartScreen.BlackBox.TextButton.MouseButton1Click then
			wait(3)
			char.HumanoidRootPart.Anchored = false
		end
	end)
end)

P.S (I already have the sword welded; all I need is help with anchoring the root part of the character.)

You’re not referencing the correct GUI instance. StarterGui is merely a storage container for the game’s UI, and is not where the active UI of a client resides.

“When a Player.Character spawns, the contents of their PlayerGui (if any) are emptied. Children of the StarterGui are then copied along with their descendants into the PlayerGui. Note, however, that LayerCollector objects such as ScreenGuis with their ResetOnSpawn property set to false will only be placed into each player’s PlayerGui once and will not be deleted when the Player respawns.”

You must access the client’s PlayerGui folder instead

You’re not using events correctly. They are not booleans that you can use in if-statements. They’re RBXScriptSignal objects. Reading an event in an if-statement will always pass the if-statement as objects are truthy (not false/nil). You mean to write:

textButton.MouseButton1Click:Once(function()
    humanoidRootPart.Anchored = false
end)

You’re pulling variables from nowhere; Weld and plr is undefined in your script, and attempting to interact with an undefined variable will result in indexing errors

Along with what @Ziffixture stated, the PlayerAdded event is a part of the Players service not the player object, so replace this line:

With this one:

game.Players.PlayerAdded:Connect(function(plr)

I was meaning to copy the whole script I don’t know how I didn’t catch that, but all the items are defined in the script

local RS = game:GetService("ReplicatedStorage")
local plr = game:GetService("Players")
local Weld = RS.IdleWeaponWeld
local Sword = RS.Sword

so, this would be better to do if I’m defining the player that was added?

That doesn’t seem to be the issue, is there any errors after you made the switch to the server?

no, after I switched it to server it did the same thing as the local script one it gave me no errors in the output.

It works perfectly fine for me, so it may be due to the weld or sword model, but at the same time I could be wrong.
image

1 Like

yep, I believe it was because all the sword welds were on top of the anchor.

1 Like

alright, I wish you luck dude!!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.