I’m making a game where you press a button and a random event happens.
(just making it for practising)
The problem is that when, for example I get number 1 it plays the same number every time unless I restart. I’m wondering what would be the best method to make it random every time you click the button, rather than the game deciding the number when someone joins and keeping it.
I know I’m dumb but I’m fairly new to scripting.
local Trigger = script.Parent
local Debounce = false
local MouseClicked = script.Parent.ClickDetector
local mathRandom = math.random(1,2)
Baseplate = workspace.BetterBasePlates
function onMouseClick()
if not Debounce then
Debounce = true
if mathRandom == 1 then
print("1")
Baseplate.Color = Color3.fromRGB()(255, 0, 0)
wait(4)
Baseplate.Color = Color3.fromRGB()(0, 255, 0)
end
if mathRandom == 2 then
print("2")
Baseplate.Color = Color3.fromRGB(255, 120, 0)
wait(4)
Baseplate.Color = Color3.fromRGB(0, 255, 0)
end
wait(6)
Debounce = false
end
end
MouseClicked.MouseClick:Connect(onMouseClick)