Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you add a hat to a player?

Asked by 9 years ago

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

Log in to vote
0
Answered by
lukeb50 631 Moderation Voter
9 years ago

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

0
Thanks for the help, the Hat Store now works! Aerodos12 70 — 9y
Ad

Answer this question