Hello all! I am creating a GUI that when clicked gives your character an accessory in ServerStorage. I don't understand as to why this doesn't work, as it says it should run!
local playerModel = game.Players.LocalPlayer local Character = workspace:FindFirstChild(playerModel.Name) script.Parent.MouseButton1Click:Connect(function() if Character:FindFirstChild("Humanoid") then game.ServerStorage.BlackHair:Clone().Parent = Character script.Parent.Parent:Destroy() end end)
You need to set the position of the hat. You cannot just assign its parent to Character without giving it any info on where its going to go.
local playerModel = game.Players.LocalPlayer local Character = workspace:FindFirstChild(playerModel.Name) script.Parent.MouseButton1Click:Connect(function() if Character:FindFirstChild("Humanoid") then local h = Instance.new("Hat") local p = Instance.new("Part") h.Name = "Hat" p.Parent = h p.Position = hit.Parent:findFirstChild("Head").Position p.Name = "Handle" p.formFactor = 0 p.Size = Vector3.new(1, 0.4, 1) p.BottomSurface = 0 p.TopSurface = 0 p.Locked = true game.ServerStorage.BlackHair:Clone().Parent = Character h.Parent = Character h.AttachmentForward = Vector3.new (-0, -0, -1) h.AttachmentPos = Vector3.new(0, 0.4, 0) h.AttachmentRight = Vector3.new (1, 0, 0) h.AttachmentUp = Vector3.new (0, 1, 0) wait(5) end end)
My code may not all be correct but I hope you understand that you'll need to give it coordinates.