#Changing the avatar when changing the team

1 messages · Page 1 of 1 (latest)

covert gust
#

So like there is zero youtube tutorials on how to do that, and i dont even code honestly, starting to learn lua evilcat

agile hill
#

i have never messed with teams but the only thing coming to mind is

#

use an IF statement to check which team the player is on

#

then assign there avatar clothing whatever you want

#

since team is a property of the player or character right?

covert gust
#

there is lobby

#

then there is killer

#

and survivor

#

like in forsaken

#

you change your avatar when you play as killer

#

i think

#

i dont really know how it works

agile hill
#

alright so how i would do it
first create two team objects inside of teams and name them

#

ill send a working script with comments

agile hill
languid jayBOT
#

studio** You are now Level 3! **studio

agile hill
#
local Teams = game:GetService("Teams") -- team service
local Players = game:GetService("Players") -- getting the players

local function assignRoles()
    -- defining the team names to make it more readable and clear
    local killerTeam = Teams.Killer
    local survivorTeam = Teams.Survivor
    
    local killer = false -- to control a while loop later to make sure only 1 player is a killer

    local allPlayers = Players:GetPlayers() -- getting all players
    
    -- here we just loop the players to make them default to survivor
    for _, player in pairs(allPlayers) do
        if player.TeamColor ~= "Really Red" then -- only the killer uses Really Red team colour 
            player.Team = survivorTeam -- sets them to survivor team
        end
    end

    if killer == false then -- if there is no killer
        for _, player in pairs(Players:GetPlayers()) do
            while killer == false do -- while the killer isnt found do the indented code
                player.Team = killerTeam -- set the player to killer
                killer = true -- set the killer to true to break the loop so no other players get killer
                break
            end
        end
    end
end
assignRoles()

print("script loaded")
#

this is my take

#

make sure your roles have "AutoAssignable" off in the properties

covert gust
#

What did you

#

How

#

Do you have any good Lua tutorials? @agile hill like I'm new new new

languid jayBOT
#

studio** You are now Level 1! **studio

agile hill
#

im also somewhat new so this wont take you that long to get to trust

#

This is the first episode and beginning to become a Roblox Scripter/Game Developer! With 3 playlists (Beginner, Advanced, GUI) containing 50+ videos and 30+ hours of content, I will guide you through this journey to start making the games you want to create on Roblox!

DISCORD 📜
Join my Discord Community if you want scripting help, participat...

▶ Play video
#

He has a great series

#

Beginner's Roblox Scripting Tutorial #1 - Roblox Studio Basics (Beginner to Pro 2019)

Link to Beginner's Tutorial Series:
https://www.youtube.com/playlist?list=PLhieaQmOk7nIfMZ1UmvKGPrwuwQVwAvFa

Link to download Roblox Studio:
https://www.roblox.com/create

Social Media:
https://twitter.com/realtapwater
https://instagram.com/realtapwater

New...

▶ Play video
#

and him

#

just mess around with scripting

covert gust
#

Like I Don’t understand

#

Also thanks

agile hill
#

first learn the fundamentals
IF statements loops like FOR WHILE
then just learn how to use the explorer
how do you access a parts colour
or a players name

#

do an hour a day and trust me youll be much better than i am now soon

#
function ChangeAvatar()

    for _, player in pairs(game.Players:GetPlayers()) do
        local char = player.Character
        if not char then continue end -- if there is no character its a saftey check

        local humanoid = char:FindFirstChildOfClass("Humanoid") -- humanoid stores properties of the player such as there clothing or body colours
        if not humanoid then continue end

        if player.TeamColor == BrickColor.new("Really red") then -- if they are a killer

            local desc = humanoid:GetAppliedDescription() -- GetAppliedDescription this is all about a players appearance and lets you modify
            local red = BrickColor.new("Really red").Color -- setting a variable "red" to Really Red 
            
            -- changing the players body colours to red
            desc.HeadColor = red
            desc.LeftArmColor = red
            desc.RightArmColor = red
            desc.LeftLegColor = red
            desc.RightLegColor = red
            desc.TorsoColor = red
            
            -- taking off their accessories, you can also change them if you wish
            desc.FaceAccessory = ""
            desc.BackAccessory = ""
            desc.FrontAccessory = ""
            desc.NeckAccessory = ""
            desc.ShouldersAccessory = ""
            desc.WaistAccessory = ""
            
            -- applying the changes
            humanoid:ApplyDescription(desc)
            
        else
            -- the player isnt a killer
            print("change outfit the same way or leave it")
        end
    end
end
agile hill
covert gust
#

Txt file

#

And put it in

#

Somewhere

#

?

agile hill
#

nah this is just a Script inside StarterCharacterScripts

#

youll have to learn when to use localscript when to use a normal serverscript and when to use module script

#

client vs server

#

then look into remote events and remote functions

#

mess around with them and you will understand