I’m trying to make a randomize color game, where randomized color plates will be generated and all of them will be destroyed and one will remain. So i want the frame to change to the remaining color. But it gave me an error "Unable to cast value to Object "
server script
local Plates = game.Workspace.Plates.Model:GetChildren()
local RemainingColorA = game.ReplicatedStorage:WaitForChild("RemainingColor")
local RandomColors = {
BrickColor.new("White"),
BrickColor.new("Really black"),
BrickColor.new("Really red"),
BrickColor.new("Really blue"),
BrickColor.new("New Yeller"),
BrickColor.new("Cyan"),
BrickColor.new("Magenta"),
BrickColor.new("Pink"),
BrickColor.new("Deep orange"),
BrickColor.new("Brown"),
}
local waitTime = 7
local waitBetween = 3
while task.wait() do
for _, v in Plates do
local randomIndex = math.random(1, #RandomColors)
local randomColor = RandomColors[randomIndex]
v.Transparency = 0
v.CanCollide = true
v.BrickColor = randomColor
end
local randomIndex2 = math.random(1, #RandomColors)
local remainingColor = RandomColors[randomIndex2]
RemainingColorA:FireClient(remainingColor)
print(remainingColor)
task.wait(waitTime)
for _, v in Plates do
if v.BrickColor ~= remainingColor then
v.Transparency = 1
v.CanCollide = false
end
end
task.wait(waitBetween)
waitTime = waitTime - 0.4
waitBetween = waitBetween - 0.02
end
local script
local Frame = game.StarterGui.Color.Frame.Frame
local Text = game.StarterGui.Color.Frame.TextLabel
local RemainingColorA = game.ReplicatedStorage:WaitForChild("RemainingColor")
RemainingColorA.OnClientEvent:Connect(function(a)
Frame = a
Text = tostring(a)
end)