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

Value is not a Valid Member of BrickColor?

Asked by 2 years ago

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?

Properties

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

0
Because you need to do Part.BrickColor = BrickColor.new("Really red") or Part.Color = Color3.fromRGB("255,0,0") I think? Krektonix_Youtube 85 — 2y
0
What is the ClassName of the TeamColor object? Is it a Team instance or a BrickColorValue? Y_VRN 246 — 2y
0
TeamColor is property of player, by using . you are going to index properties first, then children, you should rename the value or use :FindFirstChild("TeamColor").Value imKirda 4491 — 2y

2 answers

Log in to vote
0
Answered by 2 years ago

Value is not an element of TeamColor. You have to use BrickColor :

local AddTeamColor = TeamColor:Clone()
AddTeamColor = BrickColor.new("Blue")
AddTeamColor.Parent = player
Ad
Log in to vote
0
Answered by
AronYstad 101
2 years ago

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.

Answer this question