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

Can someone help me with this local script?

Asked by 10 years ago

It's located in Starterpack!

local player = game.Players.LocalPlayer
local C = '"' .. player.TeamColor .. '"' -- the error is here!

local torso = player.Character:FindFirstChild("Torso")
local head = player.Character:FindFirstChild("Head")
local larm = player.Character:FindFirstChild("Left Arm")
local rarm = player.Character:FindFirstChild("Right Arm")
local lleg = player.Character:FindFirstChild("Left Leg")
local rleg = player.Character:FindFirstChild("Right Leg")

torso.BrickColor = BrickColor.new(C)
head.BrickColor = BrickColor.new(C)
larm.BrickColor = BrickColor.new(C)
rarm.BrickColor = BrickColor.new(C)
lleg.BrickColor = BrickColor.new(C)
rleg.BrickColor = BrickColor.new(C)
0
Why do you say the error is there? BlueTaslem 18071 — 10y

1 answer

Log in to vote
-1
Answered by
Ekkoh 635 Moderation Voter
10 years ago

The error was because you were trying to concatenate a player's TeamColor (a BrickColor Value) into a string which doesn't make sense. What you were trying to do is concatenate the Name of the color into the string. You wouldn't have needed the extra quotes either. Quotation marks ( '', "", [[]] ) denote a string in Lua. Anyway, all you needed to say was C = player.TeamColor and that way you don't need to use BrickColor.new(C) because C is already a BrickColor value.

local player = game.Players.LocalPlayer
local C = player.TeamColor -- a BrickColor value

local torso = player.Character:FindFirstChild("Torso")
local head = player.Character:FindFirstChild("Head")
local larm = player.Character:FindFirstChild("Left Arm")
local rarm = player.Character:FindFirstChild("Right Arm")
local lleg = player.Character:FindFirstChild("Left Leg")
local rleg = player.Character:FindFirstChild("Right Leg")

torso.BrickColor = C -- Setting BrickColors of all these parts to a BrickColor value (makes sense, right?)
head.BrickColor = C
larm.BrickColor = C
rarm.BrickColor = C
lleg.BrickColor = C
rleg.BrickColor = C
Ad

Answer this question