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

How to change the height values if they are on a certain team roblox?

Asked by 4 years ago

I am making a adopt and raise type of game, and I was wondering how I would change a players height and width value to be set depending on their team they choose. Example: when they choose the kid team, how would I make the kids team change their size to a size I can make it that will represent a kid.

2 answers

Log in to vote
0
Answered by
Elyzzia 1294 Moderation Voter
4 years ago

if your game uses R15, you can just use the body scaling values in the humanoid

you can run a function whenever the player changes their team or their character gets added to make sure that they're always that size

local teamSizeIndex = {
    -- your teams don't have to be named the same way, this is just an example
    Adult = 1,
    Teenager = 0.75,
    Child = 0.5
}

game.Players.PlayerAdded:Connect(function(player)
    local function updateSize()
        wait(0.1) -- give a little bit of time for things to load
        if player.Team then -- make sure the player has a team, or else the function will error
            local char = player.Character
            local size = teamSizeIndex[player.Team.Name]
            char.Humanoid.BodyHeightScale *= size -- compound operators are Awesome
            char.Humanoid.BodyWidthScale *= size
            char.Humanoid.BodyDepthScale *= size
            char.Humanoid.HeadScale *= size
        end
    end
    player.CharacterAdded:Connect(updateSize)
    player:GetPropertyChangedSignal("Team"):Connect(updateSize)
end)

if your game uses R6 then. you're screwed lol

there's no way to change body scaling with R6 unless you write your own function that manually changes the size of each limb and the position of the motor6ds on the character, which isn't exactly fun

0
I get a error that states: ServerScriptService.Script:14: attempt to perform arithmetic (mul) on Instance and number kevman599 0 — 4y
0
OOoops you have to add .Value after all the BodyScale thingies Elyzzia 1294 — 4y
0
Current Script kevman599 0 — 4y
0
local teamSizeIndex = { -- your teams don't have to be named the same way, this is just an example Parents = 1, Teens = 0.75, Kids = 0.5 } game.Players.PlayerAdded:Connect(function(player) local function updateSize() wait(0.1) -- give a little bit of time for things to load if player.Team then -- make sure the player has a team, or else the function will error local char = player.Char kevman599 0 — 4y
View all comments (5 more)
0
And it still does not work. kevman599 0 — 4y
0
what's the error now Elyzzia 1294 — 4y
0
Attempt to call a nil value kevman599 0 — 4y
0
????????????? on what line Elyzzia 1294 — 4y
0
I posted something down below, because it would not let me paste code here. kevman599 0 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
local teamSizeIndex = {
    -- your teams don't have to be named the same way, this is just an example
    Parents = 1,
    Teens = 0.75,
    Kids = 0.5
}

game.Players.PlayerAdded:Connect(function(player)
    local function updateSize()
        wait(0.1) -- give a little bit of time for things to load
        if player.Team then -- make sure the player has a team, or else the function will error
            local char = player.Character
            local size = teamSizeIndex[player.Team.Name]
            char.Humanoid.BodyHeightScale.Value *= size-- compound operators are Awesome
            char.Humanoid.BodyWidthScale.Value *= size
            char.Humanoid.BodyDepthScale.Value *= size
            char.Humanoid.HeadScale.Value *= size
        end
    end
    player.CharacterAdded:Connect(updateSize)
    player:GetPropertyChangedSignal("Team"):Connect(updateSize)
end)

Is my current code, but it now has no error. But it does not work.

0
try waiting a bit longer, otherwise idk Elyzzia 1294 — 4y
0
Did not work, and no errors. I will just give you the answer, due to I am clueless kevman599 0 — 4y

Answer this question