Anchoring then unanchoring all the parts of a character but the character cant move afterwards

I have a for i,v loop that loops through the character and anchors all of the meshparts and parts. After 8 seconds all the parts are unanchored with another for i,v loop . After everything in unanchored , the player animations come back but the player can’t move anymore. Can someone tell me why this is happening?

Hello, can you show us your script?

local event = game.ReplicatedStorage.RemoteEvent
event.OnServerEvent:Connect(function(plr,action)
if action == “TimeStop” then
local hum = game.Workspace:FindFirstChild(plr.Name).Humanoid
hum.WalkSpeed = 0
hum.JumpPower = 0
wait(1.4)
hum.WalkSpeed = 16
hum.JumpPower = 16

	local people = {}
	local workspaceObjects = game.Workspace:GetChildren()
	for i,v in pairs(workspaceObjects) do
		if v:FindFirstChild("Humanoid") then
			table.insert(people,v)
		end
	end
	local UpperTorso = game.Workspace:FindFirstChild(plr.Name).UpperTorso
	for a,characters in pairs(people) do
		if characters:FindFirstChild("UpperTorso") then
			if characters.UpperTorso ~= UpperTorso and (characters.UpperTorso.Position - UpperTorso.Position).Magnitude < 200 then
				for b,charParts in pairs(characters:GetChildren()) do
					if charParts:IsA("MeshPart") or charParts:IsA("Part") then
						charParts.Anchored = true
					end
				end
			end
		end
	end
	wait(8)
	for c,d in pairs(people) do
		for e,f in pairs(d:GetChildren()) do
			if f:IsA("MeshPart") or d:IsA("Part") then
				f.Anchored = false
				local damageTaken = require(game.ReplicatedStorage.DamageCollection)
					
				for name,damage in pairs(damageTaken) do
					game.Workspace:FindFirstChild(name).Humanoid.Health -= damage
				end
			end
		end
	end
end

if action == "Kick" then
	local playerWhoKicked = game.Workspace:FindFirstChild(plr.Name)
	local Origin = playerWhoKicked.LowerTorso.Position
	local Direction =  playerWhoKicked.LowerTorso.CFrame.LookVector * 10
	local rayCastResults = workspace:Raycast(Origin,Direction)
	if rayCastResults then
		if rayCastResults.Instance.Parent:FindFirstChild("Humanoid") then
			if rayCastResults.Instance.Parent.LowerTorso.Anchored ~= true then
				if rayCastResults.Instance.Name == "Hitbox" or rayCastResults.Instance.Parent.Name ~= playerWhoKicked.Name then
					rayCastResults.Instance.Parent.Humanoid.Health -= 10
				end	
			else
				local damageCollection = require(game.ReplicatedStorage.DamageCollection)
				local player = rayCastResults.Instance.Parent
				local plrName = player.Name
				table.insert(damageCollection,player.Name)
				if damageCollection.plrName == nil then
					damageCollection.plrName = 0
				end
				damageCollection.plrName += 10
			end
		end
	end
end

end)

Is it possible you’re not unanchoring all of the parts you’ve anchored? I haven’t checked the script.

You only need to anchor a character’s “HumanoidRootPart” to restrict their movement.

I also want to restrict the animations from playing.

Second loop doesnt unAnchor HumanoidRootPart, here’s the mistake:

if f:IsA("MeshPart") or **d**:IsA("Part") then

you should do:

if f:IsA("MeshPart") or f:IsA("Part") then

instead

Oh thanks let me check that out really quick.

Thanks so much , I didn’t see that. It is working now :smiley:

1 Like