Problem with setting AlignPosition to HumanoidRootPart

The title of this topic already describes what i am trying to do.

Here’s the code:

--local mod = require(game.ReplicatedStorage.tweenMod)

local catched = {}
local allPoses = {}


for i,v in pairs(script.Parent.Parent.Parent.Poses:GetChildren()) do
	table.insert(allPoses, v)
	print(allPoses)
end


script.Parent.Touched:Connect(function(hit)
	
	local hum = hit.Parent:FindFirstChild("Humanoid")
	
	for i,v in pairs(catched) do
		
	
	if hum and v ~= hit.Parent.Name then
		
		local character = hit.Parent.HumanoidRootPart
		table.insert(catched,hit.Parent.Name)
		print(catched)
		
		
		
		
		hum.WalkSpeed = 0
		hum.JumpPower = 0
		
		local characterAttach = Instance.new("Attachment")
		characterAttach.Name = "Attachment0"
		characterAttach.Parent = character
		
		local AlignPosition = Instance.new("AlignPosition")
		
		AlignPosition.Attachment0 = character.Attachment0
		AlignPosition.Attachment1 = allPoses[math.random(1,#allPoses)].Attachment1
		AlignPosition.Responsiveness = 100
		AlignPosition.Parent = character
		
		
		
	else
		return 
	end
	
	end
	
end)

To make it simple and short i want to make a player float to random poses (which you can see in the for loop) using alignPosition but it doesn’t even parent it to the HumanoidRootPart.

Any help will be appreciated.

Anybody?

sdfsadfdsasfdsdfa

Shouldn’t it be AlignPosition.Parent = character.HumanoidRootPart

When play testing can you click on your Player in the workspace and find the AlignPosition?

	AlignPosition.Attachment0 = character:FindFirstChild("Attachment0")

character.HumanoidRootpart because you parented the Attachment to the HumanoidRootPart FindFirstChild only does a shallow check or it only gets the children does not get descendants
also avoid using Touched part

What should i use for it then?

remember that the attachment or the alignposition doesn’t even get parented to the character

AlignPosition.Attachment0 = character:FindFirstChild("Attachment0")

this is your code see anything wrong here ?

Let me guess i had to say FindFirstChild(characterAttach)?

you parented it to HRP and then looked for it on the Character
it should be Character.Humanoirdrootpart:FindFirstChild

but the character is a variable there which refers to HRP also

(edited the post to remove misunderstandings)

Oh my bad then the problem probably lies with the fact u are using Touched Event which is not good i think it would be better to GetPartBoundsInBox And Also use a debounce so its not called multiple times.

Yeah i was thinking about that because when i used touched event it didnt even print catched table.

i already made a table for that which checks if the user is in the “catched” table if he is not then it inserts the character name into the table or else it wont check multiple times