Heya, I've created multiple scripts so that when a player clicks a button, a String Value gets cloned and inserted into the player. For some reason, I keep on getting the error "Value is not a valid member of BrickColor" in another script. Anyone know why?
String Value Giver
local Text = workspace.Intermission2 local Door = workspace.Door2 local ServerStorage = game:GetService("ServerStorage") local TeamColor = ServerStorage.TeamColor local ReadyCount = ServerStorage.ReadyCount script.Parent.ClickDetector.MouseClick:Connect(function(player) script.Parent.ClickDetector:Destroy() workspace.Intermission2.SurfaceGui.TextLabel.Text = "Please wait..." Door.CanPass.Disabled = true Door.CanCollide = true Door.Transparency = 0 local AddTeamColor = TeamColor:Clone() AddTeamColor.Value = "Blue" AddTeamColor.Parent = player ReadyCount.Value = ReadyCount.Value + 1 end)
The lines that give the Value to the player are 14-16
Teleport Script [not the full script, only included the important parts]
while wait() do if game.ServerStorage.ReadyCount.Value == 2 then local players = game:GetService("Players") for i, v in pairs(players:GetChildren()) do local telePos if v.TeamColor.Value == "Red" then telePos = CFrame.new(14,2,-18) elseif v.TeamColor.Value == "Blue" then telePos = CFrame.new(14,2,13) end local char = v.Character if char then local humanoidRootPart = char.HumanoidRootPart if humanoidRootPart then humanoidRootPart.CFrame = telePos end end end end end
The error occurs at line 7
All help is greatly appreciated, thank you :D
Value is not an element of TeamColor. You have to use BrickColor :
local AddTeamColor = TeamColor:Clone() AddTeamColor = BrickColor.new("Blue") AddTeamColor.Parent = player
I think the problem is that you add a string value called TeamColor, while there is already a brickcolor property called TeamColor. So when you try to get the value, it checks the property, which doesn't have a value property. To work around this, if you want it to be the team color, you can simply set the player's team color using
player.TeamColor = BrickColor.new("Blue")
Or, if you want it to be a string value, name it something other than TeamColor, so the game doesn't think you're referring to the property.