door = script.Parent local list = game.ServerStorage.Colors:GetChildren() local list2 = game.Workspace.Colors4.pads:GetChildren() local pm = game.ServerStorage.pm.Value function onChatted(msg, recipient, speaker) local num = 0 local source = string.lower(speaker.Name) msg = string.lower(msg) if (msg == ":randomize") then repeat list2[math.random(#list2)].BrickColor = list[math.random(#list)].Value num = num + 1 print(num) wait() until num == 9 end num = 0 end function onPlayerEntered(newPlayer) newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end) end game.Players.ChildAdded:connect(onPlayerEntered)
The script I have works fine but it has 1 problem. I do not want the color to be repeated onto any of the bricks. I tried using variables in a earlier version of this script but that did not work.
Thanks if you decide to help out, thanks if you just read this. - UltChowsk
door = script.Parent local list = game.ServerStorage.Colors:GetChildren() local list2 = game.Workspace.Colors4.pads:GetChildren() local pm = game.ServerStorage.pm.Value function onChatted(msg, recipient, speaker) local num = 0 -------------------------- function colorCheck(tab,val) -- function, so you can do multiple times for _,v in pairs (tab) do if v == val.Value then return false else return true end end end ------------------------------ local source = string.lower(speaker.Name) msg = string.lower(msg) ----------------------------------- local colors = {} -- table for brickcolors ----------------------------------- if (msg == ":randomize") then repeat --------------------------------- function change() -- so you can do multiple times local c = list[math.random(#list)] if colorCheck(colors,c) == true then list2[math.random(#list2)].BrickColor = c.Value else change() end end change() -------------------------------- num = num + 1 print(num) wait() until num == 9 end num = 0 end function onPlayerEntered(newPlayer) newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end) end game.Players.ChildAdded:connect(onPlayerEntered)
I fixed it, I used another script to reset the values and it all works fine now. :D