Math.random help!

Hey!

i need a script, remember there 3 button (Button1,Button2,Button3) in the map, when someone clicked the button1 it will be transparent to 1 and random change to other button(RANDOM 2 AND 3)(tranparent 0) position, if no one click button1 (60 second) it will transparent 1 and change other button(RANDOM 2 AND 3) position

just like the piggy game key random spawn position

If you don’t understand here the video

I already try it it doesn’t work

Sorry for bad English :frowning:

1 Like

Edit:

local buttonFolder = script.Parent

local buttons = {buttonFolder.Button1,buttonFolder.Button2,buttonFolder.Button3}

local function onClicked(button)
	if button.Transparency==0 then
		button.Transparency = 1

		local nextButton = button
		while nextButton==button do
			nextButton = buttons[math.random(1,3)]
		end

		nextButton.Transparency = 0
	end
end

for _,part in buttons do
	part.ClickDetector.MouseClick:Connect(function()
		onClicked(part)
	end)
	part.Transparency=1
end

buttons[math.random(1,3)].Transparency=0
3 Likes

thanks let me try btw sorry for bad english :'/

2 Likes

Hey!

It doesn’t work D:
i alreadyput name on the part and folder

Andamanians

1 Like

You are right :smiley: it was badly broken. Sorry for inconvenience. Try the edit, see above.

2 Likes

Hey!

It doesn’t work i already check all of them! btw can you try test it on your roblox studio?

1 Like

Please stop posting this topic MULTIPLE TIMES.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.