I am trying to make it so that the player could equip a halo, but every time I try to equip a halo I get the error: "Parent cannot be assigned to" I don't know what could be causing the issue. Here is the server script:
local function equipHalo(plr,color)
if plr.HaloInventory:FindFirstChild(color.."Halo") == nil then return "halo" end
if plr.HaloInventory:FindFirstChild(color.."Halo") then
local clone = game.ReplicatedStorage.Halos[color.."Halo"]:Clone()
local char = plr.Character
if clone ~= nil and char ~= nil then
if char:FindFirstChild(plr.Name.."'s Halo") then char[plr.Name.."'s Halo"]:Destroy() end
clone.Name = plr.Name.."'s Halo"
clone.CFrame = char.Head.CFrame
local size = clone.Size
local attatchmentchar = Instance.new("Attachment")
attatchmentchar.Visible = false
attatchmentchar = Vector3.new(0,2.5,0) + size
attatchmentchar.Parent = char:WaitForChild("HumanoidRootPart")
local attatchmenthalo = Instance.new("Attachment")
attatchmenthalo.Visible = false
attatchmenthalo.Parent = clone
local alignposition = Instance.new("AlignPosition")
alignposition.MaxForce = 25000
alignposition.Attachment0 = attatchmenthalo
alignposition.Attachment1 = attatchmentchar
alignposition.Responsiveness = 200
alignposition.Parent = clone
local alignorientation = Instance.new("AlignOrientation")
alignorientation.MaxTorque = 25000
alignorientation.Attachment0 = attatchmenthalo
alignorientation.Attachment1 = attatchmentchar
alignorientation.Responsiveness = 200
alignorientation.Parent = clone
clone.Parent = char
return "yes"
end
end
end
game.ReplicatedStorage.Remotes.EquipHalo.OnServerInvoke = equipHalo
