Help with equipping stuff on player

So i made an armor suit, i tested it by spawning my character in and creating the constraint manually.
afterwards, i decided to write a script that would make the player equip the armor upon clicking it.
Though it seems i’m doing something wrong, as nothing is happening.
Here’s the code:

local players = game:GetService("Players")
local player = players.LocalPlayer.Character:FindFirstChildWhichIsA("Humanoid")


script.Parent.ClickDetector.MouseClick:Connect(function()
	if script.Parent.ClickDetector.MouseClick then
		local ArmorClone = script.Parent.Parent:Clone()
		local Joint = Instance.new("RigidConstraint")
		Joint.Parent = ArmorClone
		Joint.Attachment0 = player.Parent:FindFirstChild("RootAttachment")
		Joint.Attachment1 = ArmorClone
		end
end)

i assume it’s wrong in terms of linking it all to actual player model, but i don’t understand what am i doing wrong in particular.

local click = script.Parent
local part = click.Parent
local model = part.Parent

click.MouseClick:Connect(function(player)
	local character = player.Character
	local hrp = character:WaitForChild("HumanoidRootPart")

	local modelClone = model:Clone()
	
	local attachment1 = Instance.new("Attachment")
	attachment1.Parent = hrp
	
	local attachment2 = Instance.new("Attachment")
	attachment2.Parent = modelClone.Part
	
	local joint = Instance.new("RigidConstraint")
	joint.Attachment0 = attachment1
	joint.Attachment1 = attachment2
	joint.Parent = character
	
	modelClone.Parent = workspace
end)

Server script.

“game.Players.LocalPlayer” isn’t defined in server scripts.

Does not work, whether i put it in actual model itself or ServerScriptService, no difference at all

What type of script is this and where is it located?

You don’t place it inside the model, it should go inside the click detector.

Neither local nor normal script works, even if placed inside click detector

Then you should be sharing any errors you receive in console.

I looked further into the issue, Rigid constraints work fine, but cloning process is botched.
Edit: I made a new line of code right bellow line that does the actual cloning:

modelClone.Parent = character

And that seemed to fix it, while character wears it wrong, i’ll figure out that issue myself.

local click = script.Parent
local part = click.Parent
local model = part.Parent

click.MouseClick:Connect(function(player)
	local character = player.Character
	local hrp = character:WaitForChild("HumanoidRootPart")

	local modelClone = model:Clone()
	
	local attachment1 = Instance.new("Attachment")
	attachment1.Parent = hrp
	
	local attachment2 = Instance.new("Attachment")
	attachment2.Parent = modelClone.Part
	
	local joint = Instance.new("RigidConstraint")
	joint.Attachment0 = attachment1
	joint.Attachment1 = attachment2
	joint.Parent = character
	
	modelClone.Parent = workspace
end)

Here’s the script I ended up using.

Model file:
repro.rbxm (3.8 KB)

End result:
https://gyazo.com/61b68cd2f0f9625f5cf3f0c3942df666