Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I'm making 4 corners and need a script to randomly pick blue, red, yellow or green?

Please answer me! -cris

1 comment

0

Please do not make blatant requests like these in the future.

2 answers

You use the math.random function. I would group all the corners into a model then do...

corners = {}

function getcorners()
local corner = game.Workspace.CornersModel:GetChildren() -- CHANGE TO LOCATION OF CORNERS
for i=1, #corner do
table.insert(corners, , corner[i])
end
end

function randomcorner()
getcorners()
local c = math.random(1, #corners)
curcorner = c.Name
msg = Instance.new("Message", Workspace)
msg.Text = "The corner selected is "..curcorner
wait(2)
msg:Destroy()
end

while wait() do -- Change the time if you want.
randomcorner()
end

I would try something like this:

colors = {"Red","Green","Blue","Yellow"} -- Change to exact colors from roblox
corners = {"corner1Part","corner2Part","corner3Part","corner4Part"} --Change to the names of the corners

c = 1

while c < #corners and c < #colors do
	newColor = colors[math.random(#colors)]
	corners[c].BrickColor = BrickColor.new(newColor)
	part = game.Workspace:FindFirstChild(corners[c]) -- change game.Workspace to the file location
	part.CanCollide = false
	msg = Instance.new("Message",Workspace)
	msg.Text = "Corner: " .. corners[c] .. "was eliminated!"
	table.remove(colors,newColor)
	c = c + 1
end

I hope this helps.

EDIT: Added the extra things you wanted

1 comment

1

It helps but I want to make the part cancollide = false and have a message that says "color" was elimated. also i want time for ppl to get to a square

This discussion is preserved as it was. New answers, comments, and votes are closed.