local player = script.Parent.Parent.Parent
local f = script.Parent.ScrollingFrame:GetChildren()
for i=1,#f do
local face = f[i]
if face.Name == "Face" or face.Name == "Face1" or face.Name == "Face2" then
face.MouseButton1Down:connect(function()
player.Character.Head.face.Texture = face.Image
end)
end
end
try
player = game.Players.LocalPlayer
or
player = script:FindFirstAncestorWhichIsA("Player")
Probably It is because when the script runs the Character dont loaded already, just try use
local Character = Player.Character or Player.CharacterAdded:Wait()
That basically checks if Character exist and If It dont exist It Wait the Character to load
local players = game:GetService("Players")
local player = players.LocalPlayer or players.PlayerAdded:Wait()
local character = player.Character or player.CharacterAdded:Wait()
local head = character:WaitForChild("Head")
local f = script.Parent:WaitForChild("ScrollingFrame"):GetChildren()
for i, face in pairs(f) do
if face.Name == "Face" or face.Name == "Face1" or face.Name == "Face2" then
face.MouseButton1Down:Connect(function()
if head:FindFirstChild("face") then
head:WaitForChild("face").Texture = face.Image
end
end)
end
end