Hello, everyone.

I have currently run into an issue with trying to clone an Accessory from ReplicatedStorage to the Player's Head and upon testing in Play mode it returns with the hat cloning, but not to the player. Instead it appears in Workspace in it's set position in Replicated Storage and just falls to the ground. Here is what my script looks like:

local player = game.Players.LocalPlayer
local humanoid = player.Character:WaitForChild("Humanoid")
local hat1 = game:GetService('ReplicatedStorage'):WaitForChild('Hat1'):WaitForChild('Hat')

function click()
player.PlayerGui['3D Shop Gui'].ShopFrame.ClickSound:Play()
local Head = player.Character:FindFirstChild("Head")
local Weld = Instance.new("Weld")
Weld.Part0,Weld.Part1 = Head,hat1.Center
Weld.C0 = CFrame.new(0,0.5,0)
Weld.C1 = player.Character.Head.CFrame
humanoid:AddAccessory(hat1)
player.PlayerGui['3D Shop Gui'].ShopFrame.BUYINGFRAME.Money.Text = "Equip"
player.PlayerGui['3D Shop Gui'].ShopFrame.BUYINGFRAME.BuyButton.Visible = false
player.PlayerGui['3D Shop Gui'].ShopFrame.BUYINGFRAME.BuyHat1.Visible = true
player.PlayerGui['3D Shop Gui'].ShopFrame.BUYINGFRAME.BuyHat2.Visible = false
player.PlayerGui['3D Shop Gui'].ShopFrame.BUYINGFRAME.BuyHat3.Visible = false
end

script.Parent.MouseButton1Down:connect(click)

All comments and suggestions are welcome. Thank you, for your time.

(Replicated Storage -> Hat1 (model) -> Hat (Accessory) -> Center (Part) & Union (Union)

2 comments

0

That is a LocalScript, so even if you manage to get it to work, other players will not see the hat on player's character. You should keep your assets in ServerStorage, and clone them via server script. BTW where exactly are you cloning the hat?

0

@sleazel I'm cloning them from a button within a Shop Gui. The Hats are in Replicated Storage.