I am trying to make a script that changes the person's clothing when they click a model. You can also buy a pass that gives you the hair!

local clickDetector = script.Parent
local currencyname = "Tokens"
local outfitname = "Cool Blue Outfit"
local hair = script.Parent.Parent.Parent.BrownCharmerHair
local faceid = script.Parent.Parent.Parent.Head.face.Texture
local price = 50
local function onMouseClick(player)
local shirtid = script.Parent.Parent.Parent.Shirt.ShirtTemplate
local pantsid = script.Parent.Parent.Parent.Pants.PantsTemplate
    clickDetector.MouseClick:connect(function(click)
        local char = click.Character
       if click:FindFirstChild("leaderstats") then
	         if player.leaderstats[currencyname].Value < price then
		     game.Lighting.ErrorNoFunds:Clone().Parent = click.PlayerGui
         wait(0.1)
click.PlayerGui.ErrorNoFunds.ErrorFrame:TweenPosition(UDim2.new(0.5,-300,0.5,-50), "In", "Bounce", 1)
wait(2)
click.PlayerGui.ErrorNoFunds.ErrorFrame:TweenPosition(UDim2.new(0.5,-300,0.5,-590), "Out", "Bounce", 1)
wait(0.1)
click.PlayerGui.ErrorNoFunds:Destroy()
	else
		if char.Pants.PantsTemplate == pantsid then
game.Lighting.AlreadyOwns:Clone().Parent = click.PlayerGui
wait(0.1)
click.PlayerGui.AlreadyOwns.MainFrame:TweenPosition(UDim2.new(0.5,-300,0.5,-50), "In", "Bounce", 1)
wait(2)
click.PlayerGui.AlreadyOwns.MainFrame:TweenPosition(UDim2.new(0.5,-300,0.5,-590), "Out", "Bounce", 1)
wait(1.2)
click.PlayerGui.AlreadyOwns:Destroy()
else
            char.Shirt.ShirtTemplate = shirtid
            char.Pants.PantsTemplate = pantsid
            if player.DoesHaveFaces.Value == true then
	          char.Head.face.Texture = faceid
end
            if player.DoesHaveHair.Value == true then
	     char.Humanoid:AddAccessory(hair:Clone())
end
        if click:FindFirstChild("leaderstats") then
	click.leaderstats[currencyname].Value = click.leaderstats[currencyname].Value -price
	game.Lighting.PurchasedItem:Clone().Parent = player.PlayerGui
wait(0.1)
click.PlayerGui.PurchasedItem.PurchasedItemMain:TweenPosition(UDim2.new(0.5,-300,0.5,-50), "In", "Bounce", 1)
click.PlayerGui.PurchasedItem.PurchasedItemMain.SuccessText.Text = "Purchase success! Thanks for buying "..outfitname.."!"
wait(4)
click.PlayerGui.PurchasedItem.PurchasedItemMain:TweenPosition(UDim2.new(0.5,-300,0.5,-590), "Out", "Bounce", 1)
wait(1)
click.PlayerGui.PurchasedItem:Destroy()
end
	end
end
end
end)
end
clickDetector.MouseClick:connect(onMouseClick)

You can see in the ~~~~~~~~~~~~~~~~~ player.DoesHaveHair

it will put it in the player.
But now it just clones it in the same position and puts it in the character. 
How do I make the clone go on the player's head?

1 comment

0

Sorry if my code is messy!