Help with Server Script [MINIGAME]

So I am having 2 problems with my server script that I wrote for a mini-game styled to Super Mario Party with the Colored Plates. Problem 1 would be the fact that I can’t change the color of the frame in the Model to the color that is randomly chosen and problem number 2 would be that I would need some guidance regarding looping the entire thing, here is the code.

---------------------
print("server intializing...")
local time_p = 4
local RoundStatus = game.ReplicatedStorage.RoundStats.RoundStatus

local TweeningModule = require(game.ReplicatedStorage.Common.tweening)
local RandomChildren = game.Workspace.Plates:GetChildren()
local RandomColor = RandomChildren[math.random(#RandomChildren)]

local function Reset()
	TweeningModule.Tween(game.Workspace.Plates.White, 12.717)
	TweeningModule.Tween(game.Workspace.Plates.Red, 12.717)
	TweeningModule.Tween(game.Workspace.Plates.Pink, 12.717)
	TweeningModule.Tween(game.Workspace.Plates.Yellow, 12.717)
	TweeningModule.Tween(game.Workspace.Plates.Green, 12.717)
	TweeningModule.Tween(game.Workspace.Plates.Blue, 12.717)
	TweeningModule.Tween(game.Workspace.Plates.Orange, 12.717)
end

local function ChangeTabels(Color)
	game.Workspace.Tabel1.Main.SurfaceGui.Frame.BackgroundColor3 = Color3.fromRGB(Color)
	game.Workspace.Tabel2.Main.SurfaceGui.Frame.BackgroundColor3 = Color3.fromRGB(Color)
	game.Workspace.Tabel3.Main.SurfaceGui.Frame.BackgroundColor3 = Color3.fromRGB(Color)
	game.Workspace.Tabel4.Main.SurfaceGui.Frame.BackgroundColor3 = Color3.fromRGB(Color)
end

while wait(5.5) do
	wait(3)
	if RandomColor.Name == "Red" then
		game.ReplicatedStorage.RoundStats.RoundStatus.Value = "The Color Is Red!"
		ChangeTabels(255, 89, 89)
		wait(1.5)
		TweeningModule.Tween(game.Workspace.Plates.White, -13.723)
		TweeningModule.Tween(game.Workspace.Plates.Pink, -13.723)
		TweeningModule.Tween(game.Workspace.Plates.Yellow, -13.723)
		TweeningModule.Tween(game.Workspace.Plates.Green, -13.723)
		TweeningModule.Tween(game.Workspace.Plates.Blue, -13.723)
		TweeningModule.Tween(game.Workspace.Plates.Orange, -13.723)
		wait(time_p)
		Reset()
	elseif RandomColor.Name == "White" then
		game.ReplicatedStorage.RoundStats.RoundStatus.Value = "The Color Is White!"
		ChangeTabels(248, 248, 248)
		wait(1.5)
		TweeningModule.Tween(game.Workspace.Plates.Red, -13.723)
		TweeningModule.Tween(game.Workspace.Plates.Pink, -13.723)
		TweeningModule.Tween(game.Workspace.Plates.Yellow, -13.723)
		TweeningModule.Tween(game.Workspace.Plates.Green, -13.723)
		TweeningModule.Tween(game.Workspace.Plates.Blue, -13.723)
		TweeningModule.Tween(game.Workspace.Plates.Orange, -13.723)
		wait(time_p)
		Reset()
	elseif RandomColor.Name == "Green" then
		game.ReplicatedStorage.RoundStats.RoundStatus.Value = "The Color Is Green!"
		ChangeTabels(0, 255, 0)
		wait(1.5)
		TweeningModule.Tween(game.Workspace.Plates.White, -13.723)
		TweeningModule.Tween(game.Workspace.Plates.Pink, -13.723)
		TweeningModule.Tween(game.Workspace.Plates.Yellow, -13.723)
		TweeningModule.Tween(game.Workspace.Plates.Red, -13.723)
		TweeningModule.Tween(game.Workspace.Plates.Blue, -13.723)
		TweeningModule.Tween(game.Workspace.Plates.Orange, -13.723)
		wait(time_p)
		Reset()
	elseif RandomColor.Name == "Blue" then
		game.ReplicatedStorage.RoundStats.RoundStatus.Value = "The Color Is Blue!"
		ChangeTabels(107, 157, 184)
		wait(1.5)
		TweeningModule.Tween(game.Workspace.Plates.White, -13.723)
		TweeningModule.Tween(game.Workspace.Plates.Pink, -13.723)
		TweeningModule.Tween(game.Workspace.Plates.Yellow, -13.723)
		TweeningModule.Tween(game.Workspace.Plates.Green, -13.723)
		TweeningModule.Tween(game.Workspace.Plates.Red, -13.723)
		TweeningModule.Tween(game.Workspace.Plates.Orange, -13.723)
		wait(time_p)
		Reset()
	elseif RandomColor.Name == "Yellow" then
		game.ReplicatedStorage.RoundStats.RoundStatus.Value = "The Color Is Yellow!"
		ChangeTabels(220, 220, 0)
		wait(1.5)
		TweeningModule.Tween(game.Workspace.Plates.White, -13.723)
		TweeningModule.Tween(game.Workspace.Plates.Pink, -13.723)
		TweeningModule.Tween(game.Workspace.Plates.Red, -13.723)
		TweeningModule.Tween(game.Workspace.Plates.Green, -13.723)
		TweeningModule.Tween(game.Workspace.Plates.Blue, -13.723)
		TweeningModule.Tween(game.Workspace.Plates.Orange, -13.723)
		wait(time_p)
		Reset()
	elseif RandomColor.Name == "Orange" then
		game.ReplicatedStorage.RoundStats.RoundStatus.Value = "The Color Is Orange!"
		ChangeTabels(239, 184, 56)
		wait(1.5)
		TweeningModule.Tween(game.Workspace.Plates.White, -13.723)
		TweeningModule.Tween(game.Workspace.Plates.Pink, -13.723)
		TweeningModule.Tween(game.Workspace.Plates.Yellow, -13.723)
		TweeningModule.Tween(game.Workspace.Plates.Green, -13.723)
		TweeningModule.Tween(game.Workspace.Plates.Blue, -13.723)
		TweeningModule.Tween(game.Workspace.Plates.Red, -13.723)
		wait(time_p)
		Reset()
	elseif RandomColor.Name.Name == "Pink" then
		game.ReplicatedStorage.RoundStats.RoundStatus.Value = "The Color Is Pink!"
		ChangeTabels(158, 20, 163)
		wait(1.5)
		TweeningModule.Tween(game.Workspace.Plates.White, -13.723)
		TweeningModule.Tween(game.Workspace.Plates.Red, -13.723)
		TweeningModule.Tween(game.Workspace.Plates.Yellow, -13.723)
		TweeningModule.Tween(game.Workspace.Plates.Green, -13.723)
		TweeningModule.Tween(game.Workspace.Plates.Blue, -13.723)
		TweeningModule.Tween(game.Workspace.Plates.Orange, -13.723)
		wait(time_p)
		Reset()
	end
end
---------------------

To loop it you could just do While True Do and reloop it however if an error rises this isn’t reliable, Instead
you can store all your functions into a module and then use 2 funcs in your normal script, 1 of them being
a intermission + player check and the other one to call each function from the module via TM.RoundStart()
TM.AssignMap()
TM.AssignWeapons()
As for your other problem you are using fromRGB which im not 100% sure why it’s not working in this scenario however using Color3.new(Color) would work (note you would need to divide each R/G/B by 255 since color new is between 0 and 1. example is Color = 155/255, 102/255 , 45/255

1 Like

Can you explain the first problem a bit more?

Are you trying to change the Frame’s color to a Part’s color?
Or are you trying to change the Frame’s color to a randomly chosen color?

There’s a lot of problems with this code, un-needed elseif statements, your ChangeTables(...) function is only sampling 1/3 color values into Color3.fromRGB instead of all three or just passing the constructed Color data, etc.

EDIT:
If my message wasn’t clear, you are trying to construct a Color but only putting the first variable passed in ChangeTables.

1 Like

Here’s an improved version that will set colours (provided your Tween module works correctly).

local time_p = 4
local RoundStatus = game.ReplicatedStorage.RoundStats.RoundStatus

local TweeningModule = require(game.ReplicatedStorage.Common.tweening)
local AllPlates = workspace.Plates:GetChildren()

local RandomSeed = Random.new()

local ColorData = {
	Red = Color3.fromRGB(255, 89, 89),
	White = Color3.fromRGB(248, 248, 248),
	Green = Color3.fromRGB(0, 255, 0),
	Blue = Color3.fromRGB(107, 157, 184),
	Yellow = Color3.fromRGB(220, 220, 0),
	Orange = Color3.fromRGB(239, 184, 56),
	Pink = Color3.fromRGB(158, 20, 163)
}

local function ChangeTabels(Color)
	game.Workspace.Tabel1.Main.SurfaceGui.Frame.BackgroundColor3 = Color
	game.Workspace.Tabel2.Main.SurfaceGui.Frame.BackgroundColor3 = Color
	game.Workspace.Tabel3.Main.SurfaceGui.Frame.BackgroundColor3 = Color
	game.Workspace.Tabel4.Main.SurfaceGui.Frame.BackgroundColor3 = Color
end

local function SetAllPlates(Number)
	for _, Object in pairs(AllPlates) do
		TweeningModule.Tween(Object, Number)
	end
end

while wait(8.5) do
	local RandomColor = AllPlates[RandomSeed:NextInteger(1, #AllPlates)]
	if RandomColor then
		local SampleName = RandomColor.Name
		local ColorSample = ColorData[SampleName]
		if ColorSample then
			game.ReplicatedStorage.RoundStats.RoundStatus.Value = "The Color Is " .. SampleName .. "!"
			ChangeTabels(ColorSample)
			wait(1.5)
			SetAllPlates(-13.723)
			wait(time_p)
			SetAllPlates(12.717)
		end
	end
end
2 Likes

Hey! It really helped me your version of the script and I modified and re-done some things and now it works! Thanks you for the help!

1 Like