So currently I’m trying to make a script either in StarterPlayerScripts or StarterCharacterScripts and the problem is that I want to grab the users head and put it on a custom character so everyone can see it but everything I’ve been trying to do isn’t working at all.
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local function onCharacterAdded(character)
-- Basic debug check to ensure script is running
print("ReplaceHeadScript is running")
-- Wait for humanoid to be present in character
local humanoid = character:WaitForChild("Humanoid", 10)
if humanoid then
print("Humanoid found in character")
else
warn("Humanoid not found in character after waiting")
return
end
-- Wait for head to be present in character
local head = character:WaitForChild("Head", 10)
if head then
print("Head found in character")
else
warn("Head not found in character after waiting")
end
local function applyDescription(character, humanoidDescription)
if humanoid then
humanoid:ApplyDescription(humanoidDescription)
print("Humanoid description applied")
else
warn("Humanoid not found in character")
end
end
local function replaceHead(character)
local success, humanoidDescription = pcall(function()
return Players:GetHumanoidDescriptionFromUserId(player.UserId)
end)
if success and humanoidDescription then
print("HumanoidDescription fetched successfully")
applyDescription(character, humanoidDescription)
-- Find the new head after applying the description
local newHead = character:FindFirstChild("Head")
if newHead then
print("New head found in character")
else
warn("New head not found after applying humanoid description")
end
else
warn("Failed to load humanoid description")
end
end
replaceHead(character)
end
-- Connect to the character added event
player.CharacterAdded:Connect(onCharacterAdded)
-- Call the function for the current character if it exists
if player.Character then
onCharacterAdded(player.Character)
end
I tried looking on fourms and everything but nothing I found can help
New contributor
Tyler Hill is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.