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)
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
.