#I have a problem with my hat giver
1 messages · Page 1 of 1 (latest)
Im using this script because of ClickD and becase i can take it off any time
ill make you a small demo with Accessories
Alright tysm
You don't have primary part cframe set
this is how you give a accessory as shown in the demo above
-- get the players humanoid
local humanoid = player.Character.Humanoid
-- get all the accessories they currently have equipped
local accessories = humanoid:GetAccessories()
-- loop all the accessories and if they already have a hat exit and do nothing
for i, accessory in accessories do
if accessory.AccessoryType == Enum.AccessoryType.Hat then
print(player.Name, "already has a hat")
return
end
end
-- if they dont have a hat lets clone the hat from ServerStorage
local hat = game.ServerStorage.MyCoolHat:Clone()
-- lets now attach the hat to there head
humanoid:AddAccessory(hat)
Oh i seee
and this is how we remove a accessory
-- get the players humanoid
local humanoid = player.Character.Humanoid
-- get all the accessories they currently have equipped
local accessories = humanoid:GetAccessories()
-- loop all the accessories and if we find a hat destroy it
for i, accessory in accessories do
if accessory.AccessoryType == Enum.AccessoryType.Hat then
accessory:Destroy()
end
end
Tysm
I saved everything, should i close post?
yes close post if your finished