What do you want to achieve?
I want to change the scale of an NPC that has a humanoid description of an avatar.
What is the issue? Include screenshots / videos if possible!
The issue is that the Values of the Humanoid Description aren’t loading fast enough for my code, and I’ve been trying things to wait for it to load. (The BodyheightScale is nil).
What solutions have you tried so far?
I’ve tried putting a RunService.Heartbeat:Wait(), I tried constantly using a while wait() do, and I tried to use repeat wait() until (obj) ~= nil.
Server Script
local userid = "2064158565"
local dummy = workspace:WaitForChild("Dummy")
local humanoid = dummy:WaitForChild("Humanoid")
local RunService = game:GetService("RunService")
local function CreateOfflineCharacter(UserID, Dummy)
local Appearance = game.Players:GetHumanoidDescriptionFromUserId(UserID)
Dummy.Humanoid:ApplyDescription(Appearance)
local name = game.Players:GetNameFromUserIdAsync(userid)
Dummy.NameDisplayDistance = 0
end
--The new animation
local ani = Instance.new("Animation", dummy)
ani.Name = "IdleAni"
ani.AnimationId = "http://www.roblox.com/asset/?id=507766388"
local animationtrack = humanoid:LoadAnimation(ani)
if humanoid then
--Manipulate body size
RunService.Heartbeat:Wait()
local bodyheight = humanoid:FindFirstChild("BodyHeightScale")
print(bodyheight)
animationtrack:Play()
animationtrack.Looped = true
end
--CreateOfflineCharacter function
local success, fail = pcall(function()
CreateOfflineCharacter(userid, dummy)
end)
if success then
print("Succeeded!")
end
if fail then
warn("Failed!")
end
Humanoid =
if not Humanoid:FindFirstChild("BodyDepthScale") then
local Value = Instance.new("NumberValue",Humanoid)
Value.Name = "BodyDepthScale"
Value.Value =
else Humanoid.BodyDepthScale.Value = end
if not Humanoid:FindFirstChild("BodyHeightScale") then
local Value = Instance.new("NumberValue",Humanoid)
Value.Name = "BodyHeightScale"
Value.Value =
else Humanoid.BodyHeightScale.Value = end
if not Humanoid:FindFirstChild("BodyProportionScale") then
local Value = Instance.new("NumberValue",Humanoid)
Value.Name = "BodyProportionScale"
Value.Value =
else Humanoid.BodyProportionScale.Value = end
if not Humanoid:FindFirstChild("BodyTypeScale") then
local Value = Instance.new("NumberValue",Humanoid)
Value.Name = "BodyTypeScale"
Value.Value =
else Humanoid.BodyTypeScale.Value = end
if not Humanoid:FindFirstChild("BodyWidthScale") then
local Value = Instance.new("NumberValue",Humanoid)
Value.Name = "BodyWidthScale"
Value.Value =
else Humanoid.BodyWidthScale.Value = end
if not Humanoid:FindFirstChild("HeadScale") then
local Value = Instance.new("NumberValue",Humanoid)
Value.Name = "HeadScale"
Value.Value =
else Humanoid.HeadScale.Value = end
Modify the script a bit and add my own, animation doesn’t work, but scaling does.
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local userid = 2064158565
local dummy = workspace:WaitForChild("Dummy")
local humanoid = dummy:WaitForChild("Humanoid")
function CreateOfflineCharacter(UserID, Dummy)
local Appearance = Players:GetHumanoidDescriptionFromUserId(UserID)
humanoid:ApplyDescription(Appearance)
--| Scale |--
local Find = {
["BodyDepthScale"] = 0.5,
["BodyHeightScale"] = 0.5,
["BodyProportionScale"] = 0.5,
["BodyWidthScale"] = 0.5,
["HeadScale"] = 0.5
}
for Name,Val in pairs(Find) do
if not humanoid:FindFirstChild(Name) then
local Value = Instance.new("NumberValue",humanoid)
Value.Name = Name
Value.Value = Val
else humanoid[Name].Value = Val end
end
-------------
-- local name = Players:GetNameFromUserIdAsync(userid)
humanoid.NameDisplayDistance = 0
end
--The new animation
local ani = Instance.new("Animation", dummy)
ani.Name = "IdleAni"
ani.AnimationId = "http://www.roblox.com/asset/?id=507766388"
local animationtrack = humanoid:LoadAnimation(ani)
if humanoid then
--Manipulate body size
RunService.Heartbeat:Wait()
animationtrack:Play()
animationtrack.Looped = true
end
--CreateOfflineCharacter function
local success = pcall(function()
CreateOfflineCharacter(userid, dummy)
end)
if success then print("Succeeded!")
else warn("Failed!") end
No set it to a number value. Sorry I just put that there meaning you could put your number there. Basically, I was wondering if the BodyDepthScale wouldn’t come out as being a child, but maybe just saying Humanoid.BodyDepthScale could work.