Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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'

4 comments

0

Hello! I noticed you haven't made an attempt to this solution. Please do. For more information, see https://idownvotedbecau.se/NoAttempt

0

You haven't posted any code either.Also see https://idownvotedbecau.se/NoCode

0

Give the error, please.

0

See my answer.

3 answers

✓ Accepted answer

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

1 comment

0

Works! Thanks a lot!

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.

6 comments

0

I tried that but it seemed not to work?

0

while wait(0.5) do

0

Huh?

0

the problem seems to be here. local humanoid = children[i].Character.Humanoid

0

Please put the code in your post so i can see it more clearly.

0

done

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.

2 comments

0

I just realized someone has already answered, you can ignore.

0

thank u tho

This discussion is preserved as it was. New answers, comments, and votes are closed.