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

Changing players proportions depending on group rank?

Asked by 5 years ago

I'm trying to make this script change the player's proportions depending on their group rank, the proportions part works correctly, but if there's no wait then the script doesn't fire correctly, the script doesn't fire after the player has died, and I want it to get every player it can.

game.Players.PlayerAdded:connect(function(Player)
    if Player:GetRankInGroup(4394297) <=2 then
    function playersize(player)
    local SizeVale = .87
    local humanoid = player.Character.Humanoid
    if humanoid then
        if humanoid:FindFirstChild("BodyHeightScale") then
            humanoid.BodyHeightScale.Value = SizeVale
        end
        if humanoid:FindFirstChild("BodyWidthScale") then
            humanoid.BodyWidthScale.Value = SizeVale
        end
        if humanoid:FindFirstChild("BodyDepthScale") then
            humanoid.BodyDepthScale.Value = SizeVale
        end
        if humanoid:FindFirstChild("HeadScale") then
            humanoid.HeadScale.Value = SizeVale
        end
    end
end
wait(3) --I want there to be no wait, but if there isn't then the script won't fire correctly
playersize(game.Players.CaptainAlien132)
--Can't figure out how to get every player
--I don't go back to proportions after I reset/die
else
    end
end)
0
I don't even know where to start with this one boys. lunatic5 409 — 5y
0
my eye balls have disintegrated INOOBE_YT 387 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

First, your code is very messy, especially at the end. Your end and the else seem to be misplaced. Read this article on how to write cleaner code. I don't mean to insult you, but it's important to have clean code so that you and others can read it.

The reason the code doesn't execute when the character respawns is because you didn't code it to do so. There is an event called CharacterAdded which fires when the character is added. Whether it be first time, or respawning.

local function playersize(character) -- Localise your variables 
    -- Declare the function outside of the events. 

    for _, v in pairs(character.Humanoid:GetChildren()) do
        -- Instead of finding each individual value, use a loop.
        if v:IsA("NumberValue") then -- if it's a value...
            v.Value = ... -- set the number 
        end
    end
    print("Character added!", character) 
end

game.Players.PlayerAdded:Connect(function(player)
    client.CharacterAdded:Connect(playersize) -- Connect function 
end)

And finally, :connect is deprecated, use :Connect.


Hopefully this answered your question and if it did, then don't forget to hit that accept button. If you have any more questions then feel free to leave them in the description below.
For next time I suggest you do a search for these kinds of things.
0
Okay, sorry for the messy code CaptainAlien132 225 — 5y
Ad

Answer this question