Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do you add a hat to a player?

I have a clothing store in my game however the hats do not fit on to the player correctly when I clone them:

local dialog = script.Parent
dialog.DialogChoiceSelected:connect(function(player,choice)
if choice == dialog.GreenHat then
 game.ReplicatedStorage.GHat:Clone().Parent = player
end
end)

It always appears on the shirt of the player instead of the face of the player. How do I fix this problem ?

1 answer

✓ Accepted answer

if you are still having this problem,here is why:

on line 4, you set the parent to the player

game.ReplicatedStorage.GHat:Clone().Parent = player

what you need to do is set the parent to the player's Character

local cara=game.Workspace:FindFirstChild(player.Name)
 game.ReplicatedStorage.GHat:Clone().Parent = cara

so the full new code would be:

local dialog = script.Parent
dialog.DialogChoiceSelected:connect(function(player,choice)
if choice == dialog.GreenHat then
local cara=game.Workspace:FindFirstChild(player.Name)
 game.ReplicatedStorage.GHat:Clone().Parent = cara
end
end)

glad this helped,

lukeb50

1 comment

0

Thanks for the help, the Hat Store now works!

This discussion is preserved as it was. New answers, comments, and votes are closed.