#Torso Colour Change

12 messages · Page 1 of 1 (latest)

celest bronze
#

Hello, I am new to coding with Roblox Studio, and am having difficulties with changing the colour of the StarterCharacter torso using a random number generator I coded.

The StarterCharacter is within StarterPlayer, and the script is inside of StarterPlayerScripts.

``​lua
local starterCharacter = game.StarterPlayer.StarterCharacter
local torso = starterCharacter:WaitForChild("Torso")

local random_number = math.random(1, 3)
print(random_number, "Torso Colour Change")

if random_number == 1 then
torso.BrickColor = BrickColor.new("Really red")
elseif random_number == 2 then
torso.BrickColor = BrickColor.new("Really blue")
elseif random_number == 3 then
torso.BrickColor = BrickColor.new("Lime green")
end
``

lilac whale
#

Use Wait() instead of :WaitForChild("Torso"): Since you're working with the StarterCharacter it might not exist immediately when the script runs Using :Wait() ensures the script waits until the character is added to the game before trying to access its Torso

#

And also use Color3 instead of BrickColor Newer scripts use Color3 for setting material colors This offers smoother color transitions and wider ranges compared to BrickColor
RGB values directly You can provide RGB values to Color3.fromRGB() to achieve the desired red, blue, and green colors

celest bronze
fast stratusBOT
#

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

celest bronze
#

Like I was able to do this with a block, however Im not sure if Im putting the script in the correct spot or if Im even calling the torso correctly

#

I found out the issue

#

lol

#

Never mind, I thought body colour and colour of the parts were 2 distinct things but iwas wrong

#

I was wrong again