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

How do I change the torso color of a player at a certain time?

Asked by 4 years ago

So basically, I'm trying to make an FPS game with a team death-match mode. I've tried multiple scripts until I realized they were pretty outdated (this, for example). Here is my code so far. I'm fully aware that the code is messy, but I am too new to coding to know how to clean it up.

The problem is that the torso color does not change nor does "red" or "blue" get printed. Here's the code:

`

while true do -- repeat forever because the game continues forever kinda like doomspire brickbattle

local color1 = BrickColor.new("Persimmon") -- red's torso color
local color2 = BrickColor.new("Medium blue") -- blue's torso color

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
    local items = character:GetChildren()

    wait(1) -- wait for it to load
    player.Neutral = false -- so the player isnt neutral

    math.randomseed(os.time())
    local team = (math.random(1,2)) -- i get a random value to indicate what team im on

repeat wait() until workspace.TeamAssign.Value == 1 -- i change it to 1 when the game starts

if team == 1 then
    print("red") -- print red to indicate im on red team
        wait()
        player.TeamColor = BrickColor.new("Medium red") -- change the team color
        character["Body Colors"]:Destroy() -- script i took
        for i = 1, #items do
            if(items[i]:IsA("Part")) then
                items[i].BrickColor = color1 -- change the torso to red?
            end
        end
else
    print("blue") -- print blue to indicate im on blue team
    wait()
    player.TeamColor = BrickColor.new("Medium blue") -- change the team color
        character["Body Colors"]:Destroy() -- script i took
        for i = 1, #items do
            if(items[i]:IsA("Part")) then
                items[i].BrickColor = color2 -- change the torso to blue?
            end
        end


    end
end)
end)
end`

Answer this question