Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How would I make players' avatar grow as their strength goes up?

Asked by 4 years ago
Edited 4 years ago

I'm trying to create a simulator, and I want to know how to make my avatar grow slightly as my strength value goes up. Please help!

Edit: The problem seems to be on line 4

while wait(0.5) do
    local children = game.Players:GetChildren()
    for i = 1, #children do
        local humanoid = children[i].Character.Humanoid
        humanoid.HeadScale.Value = children[i].leaderstats.Strength.Value/50+100
        humanoid.BodyHeightScale.Value = children[i].leaderstats.Strength.Value/50+100
        humanoid.BodyWidthScale.Value = children[i].leaderstats.Strength.Value/50+100
        humanoid.BodyDepthScale.Value = children[i].leaderstats.Strength.Value/50+100
    end
end

11:49:47.892 - ServerScriptService.Script:4: attempt to index nil with 'Humanoid'

0
Hello! I noticed you haven't made an attempt to this solution. Please do. For more information, see https://idownvotedbecau.se/NoAttempt User#30567 0 — 4y
0
You haven't posted any code either.Also see https://idownvotedbecau.se/NoCode User#30567 0 — 4y
0
Give the error, please. Qariter 110 — 4y
0
See my answer. User#30567 0 — 4y

3 answers

Log in to vote
0
Answered by 4 years ago

Like marinhren said, there are sizing options in the Humanoid. This is a way to get all players, present and future, and connect them to a function that makes them grow with strength.

local Players = game:GetService("Players") -- Get players
local Humanoid

function ConnectStrengthToSize(Player)
    coroutine.wrap(function(Player)
        Player:WaitForChild("leaderstats"):WaitForChild("Strength").Changed:Connect(function(Value) -- Wait for strength to change
            Humanoid = Player.Character.Humanoid -- Define humanoid
            Humanoid.HeadScale.Value = Value/50+100 -- Change size
            Humanoid.BodyHeightScale.Value = Value/50+100
            Humanoid.BodyWidthScale.Value = Value/50+100
            Humanoid.BodyDepthScale.Value = Value/50+100
        end)
    end)(Player) -- Run the function
end
for Index, Player in pairs(Players:GetPlayers()) do
    ConnectStrengthToSize(Player) -- Connect to size
end

Players.PlayerAdded:Connect(ConnectStrengthToSize) -- Connect to size
0
Works! Thanks a lot! Fauxriii 8 — 4y
Ad
Log in to vote
0
Answered by
Qariter 110
4 years ago
Edited 4 years ago

There are certain sizing options inside a R15 Characters's Humanoid. Changing those will change the size of the R15 Character.

e.g. BodyDepthScale.Value, BodyHeightScale.Value, etc..

Do some math to calculate the values of all the sizing.

0
I tried that but it seemed not to work? Fauxriii 8 — 4y
0
while wait(0.5) do Fauxriii 8 — 4y
0
Huh? Qariter 110 — 4y
0
the problem seems to be here. local humanoid = children[i].Character.Humanoid Fauxriii 8 — 4y
View all comments (2 more)
0
Please put the code in your post so i can see it more clearly. Qariter 110 — 4y
0
done Fauxriii 8 — 4y
Log in to vote
0
Answered by 4 years ago

Hello, you use BodyDepthScale, BodyHeightScale, BodyWidthScale and HeadScale for it. You also need Script and not LocalScript.

game.Players.PlayerAdded:Connect(function(player)

    -- Do the leaderstats here

    player.CharacterAppearanceLoaded:Connect(function(character)
        character.Humanoid:WaitForChild("BodyDepthScale").Value = -- Value here
        character.Humanoid:WaitForChild("BodyHeightScale").Value = -- Value here
        character.Humanoid:WaitForChild("BodyWidthScale").Value = -- Value here
        character.Humanoid:WaitForChild("HeadScale").Value = -- Value here
    end)
end)

Also, don't add local children = game.Players:GetPlayers() and for i = 1, #children do that isn't needed.

0
I just realized someone has already answered, you can ignore. Gabe_elvin1226aclan 323 — 4y
0
thank u tho Fauxriii 8 — 4y

Answer this question