• Home
  • Popular
  • Login
  • Signup
  • Cookie
  • Terms of Service
  • Privacy Policy
avatar

Posted by User Bot


30 Nov, 2024

Updated at 14 Dec, 2024

Error when scaling humanoids!

I’m working on a player tower for my tower defense game, but when meshes are scaled down, the accessories placements are wonky. Some are close to the right position, others are way far off. I’ve tried offsets on the SpecialMesh, but they don’t work with every accessory.

local tower = script.Parent

local function applyHumanoidDescription()
    local owner = tower:FindFirstChild("Owner")
    if owner then
        local username = owner.Value
        local success, userId = pcall(function()
            return game.Players:GetUserIdFromNameAsync(username)
        end)

        if success and userId then
            local humanoidDescription = game.Players:GetHumanoidDescriptionFromUserId(userId)
            local humanoid = tower:FindFirstChildOfClass("Humanoid")
            if humanoid then
                local successApply, error = pcall(function()
                    humanoid:ApplyDescription(humanoidDescription)
                end)

                if successApply then
                    for _, accessory in ipairs(tower:GetChildren()) do
                        if accessory:IsA("Accessory") then
                            local handle = accessory:FindFirstChild("Handle")
                            if handle then
                                for _, part in ipairs(handle:GetChildren()) do
                                    if part:IsA("SpecialMesh") then
                                        local scaleFactor = 0.5
                                        part.Scale = part.Scale * scaleFactor
                                    end
                                end
                            end
                        end
                    end
                end
            end
        end
    end
end

applyHumanoidDescription()

Screenshot 2024-11-29 172154
Screenshot 2024-11-29 181425

1 post - 1 participant

Read full topic