Minigame that kills players if they don't stand on the correct color board

  1. What do you want to achieve? Making a game where there’s a color that is picked, you have to stand on the color on a board and if you dont you die. I want to make a gui that changes the badckgroundcolor3 to a BRICK COLOR out of a table and then convert that back to a brick color for my main script,

  2. What is the issue I have NO idea how to do this…

  3. What solutions have you tried so far? Everything

The Gui’s Script for changing its color (SO FAR)

local Box = script.Parent

local BrickColors = {"Really red","Deep orange","New Yeller","Dark blue","Hot pink","Reddish Brown","Lime green","Magenta"}

local ChosenColor = BrickColors[math.random(1, #BrickColors)]

Box.BackgroundColor3 = 

The Main Part that currently only scripted to get a random brickcolor from a list and delete all parts that arent it, but Im trying to make instead of random, the Gui’s hue in brickcolor.

function findBricks(ColorParts)
	local ChosenColor = BrickColors[math.random(1, #BrickColors)]
	for k,v in pairs(ColorParts:GetDescendants()) do
		if v:IsA("BasePart") and v.BrickColor ~= BrickColor.new(ChosenColor) then
			v.Transparency = 1
			v.CanCollide = false
			print(ChosenColor)
		end
	end
end

BrickColor has a Color property that represents the BrickColor as a Color3 value.

Box.BackgroundColor3 = ChosenColor.Color

It also has a constructor that takes a Color3 value and turns it into a BrickColor.

BrickColor.new(Box.BackgroundColor3)

You can go from a BrickColor3 to a Color3 value and vice versa.

2 Likes

Nope, still doesnt work for some reaoson

“It doesn’t work” isn’t sufficient context. I’m not able to discern your exact problem besides what you’ve posted in the thread which alone isn’t much. I read through it and from what I saw it only looked like you were unsure of how to configure the BackgroundColor3 of a Gui element according to a BrickColor.

Additionally my reply mainly just points out that you can convert between BrickColor and Color3 but it’s not really a direct solution in itself. For that, I’ll need extra context behind what isn’t working exactly.

What Im saying is, the gui doesnt change at all, no errors or anything? My script is in
serverscriptservice:

local Box = game.StarterGui.ColorDisplay.ColorBox

local BrickColors = {"Really red","Deep orange","New Yeller","Dark blue","Hot pink","Reddish Brown","Lime green","Magenta"}

local ChosenColor = BrickColors[math.random(1, #BrickColors)]

Box.BackgroundColor3 = ChosenColor.Color

Do you know why it could be doing this? Thats the entire script so I have no idea… also Im saying startergui because its server

Oh, this script? There’s two problems here.

First thing is that you’re changing the StarterGui copy of the ColorDisplay Gui. The changes you’re applying would only be seen by newly spawning players (or if ResetOnSpawn is false, then new players joining your game). The server should not be managing any Guis for any reason because it has no concept of a user interface.

StarterGui’s only purpose is to replicate its contents to each player’s PlayerGui when they respawn sans ResetOnSpawn false Guis which only replicate once and don’t get cleaned when the character respawns. For this you need to have the server send clients the colour choice such as via RemoteEvent.

Next problem would exist whether or not you modify the StarterGui copy of your ColorDisplay Gui and it’s that you aren’t making a BrickColor object out of ChosenColor. Your random code selects a string from the table but does not construct a BrickColor out of the string. In that case, the BackgroundColor3 line would try to read the Color index in the string which is nil which in turn evaluates to “set the BackgroundColor3 of Box to nil” which would throw an error.

In short: you need to change how you’re getting the colour displayed on your Gui. The server should only be responsible for selecting the new colour and managing the game state based on the chosen colour but it should not be handling any visuals. The server needs to give that information to the client so that the client can set Guis and such accordingly.

1 Like

Sorry but literally none of that made sense to me, this is really confusing man…

I could break it down further if you want. Obviously cases will be different between experiences but in terms of your problem specifically and the post I made:

  1. Never touch StarterGui with scripts. Look to LocalScripts and the LocalPlayer’s PlayerGui.
    1.2. Things in StarterGui don’t show up to anyone.
  2. Use a RemoteEvent. Make the server give players the colour string with FireAllClients.
  3. Use a LocalScript to connect to the RemoteEvent and change ColorDisplay instead.
  4. Make a BrickColor after you do the randomisation for ChosenColor.
1 Like

All that just to convert a hue to brickcolor?

So if I understand correctly, you need to convert a BrickColor to a Color3 because of a gui? If so, just use GuiObject.BackgroundColor

I mean, yes. It’s not just that issue I’m addressing but once you fix that you’ll find that you’ll encounter a slew of other issues which is what my post is targeting; tackling all the issues at one go, not one at a time. Letting them not be addressed is another Scripting Support thread waiting to be created.

Im still so confused, I have 2 scripts how would I make a remote event for a color string and make a object what

Just… make them? All you’re doing is sending data over remotes, that’s it.

ColorConsumerRepro.rbxl (30.7 KB)

Here’s an example file I whipped up that’s putting my advice to practice to a degree, since I don’t currently have the time to create a near-similar repro to your current setup. The LocalScript handling the Gui’s colour is in StarterPlayerScripts and the server script handling sending the colour as well as picking a random one is in ServerScriptService.

Lol your file’s scripts are all print(“Hello world”)?

  1. place a model inside of workspace named ‘Touchpads’
  2. place bricks inside of the model preferably next to eachother like tiles
  3. place a script into serverscriptservice, name it whatever you want
  4. paste this code into your script, this is just an example.
local bricks = workspace.Touchpads:GetChildren()
local colors = {"Really blue", "Really red", "Lime green", "Deep blue", "Institutional white"}

for i,v in pairs(bricks:GetChildren()) do
	v.Touched:Connect(function(hit)
		if hit.Parent:FindFirstChild("Humanoid") then
			local character = hit.Parent
			if game.Players:GetPlayerFromCharacter(character) then
				local player = game.Players:GetPlayerFromCharacter(character)
				local playertouched = player:FindFirstChild("TouchedColor")
				if playertouched then
					playertouched.Value = v.BrickColor
				end
			end
		end
	end)
end
game.Players.PlayerAdded:Connect(function(player)
	local val = Instance.new("StringValue")
	val.Parent = player
	val.Name = "TouchedColor"
end)
while wait(1) do
	local radcolor = colors[math.random(1,#colors)]
	local radbrick = bricks:GetChildren()[math.random(1,#bricks:GetChildren())]
	radbrick.Color = radcolor
	for i,v in pairs(bricks:GetChildren()) do
		if v ~= radbrick then
			repeat wait()
				v.BrickColor = BrickColor.Random()
			until v.BrickColor ~= radcolor
		end
	end
	wait(15)
	for i,v in pairs(game.Players:GetPlayers()) do
		if v:FindFirstChild("TouchedColor") then
			if v.TouchedColor.Value ~= radcolor then
				if v.Character then
					v.Character:BreakJoints()
				end
			end
		end
	end
end

What? How is that related to my question wdym

This script is an example of how the minigame would work. You can reference it if you have any troubles with your script.

Did you read my question? I already made the minigame script, I just need to make it so theres a gui that shows a color, and that color coresponds to the chosen color of the main script

How to convert a BrickColor value to a Color3 value? - Scripting Support - DevForum | Roblox

If that’s your problem this topic may help you, since the colors you’re choosing are brick colors.

1 Like

I know how to do that, but its not working correctly