Hello, i need to do this code work:
if game.Workspace.NPC.Hair then
game.Workspace.NPC.Hair:Destroy()
The script need to detect if the NPC is using a Hair and if yes, delete it and if not... execute this:
if game.Players.LocalPlayer.Data.Hair.Value == 1 then
hair = game.ReplicatedStorage.Hair1:Clone()
hair.Name = "Hair"
hair.Parent = NPC
Full code:
local Sound = script.Parent.ClickSound
local Menu = script.Parent.Parent.Parent.HairChooser
local MenuAppearance = script.Parent.Parent.Parent.MenuAppearance
local NPC = game.Workspace.NPC
local cam = game.Workspace.CurrentCamera
function onButtonClicked()
if game.Workspace.NPC.Hair then
game.Workspace.NPC.Hair:Destroy()
end
Sound:Play()
wait(0.5)
game.Players.LocalPlayer.Data.Hair.Value = 1
wait(0.1)
if game.Players.LocalPlayer.Data.Hair.Value == 1 then
hair = game.ReplicatedStorage.Hair1:Clone()
hair.Name = "Hair"
hair.Parent = NPC
wait(0.1)
Menu.Visible = false
wait(0.1)
MenuAppearance.Visible = true
end end
script.Parent.MouseButton1Click:connect(onButtonClicked)
