Hello everyone, I am making a roblox game where when you press a button on of 2 things will happen, those 2 things are either the game can be foggy or the game could have low gravity, want it to randomly pick one of those options each time, the code below is all of the code in the button (the one that i press to make this happen) it is inside a normal script, i tried a or statement thinking it would choose between the 2 options but it seems to only always pick the first option, how would i make it randomly choose between the 2 instead of always picking the first option using the code below, i tried a or statement as you can see below but that didn't seem to work. Line 14 is where i used the statement to randomly pick between the 2 but it didn't work, any help would be great, thank you.
local lighting = game.Lighting
local button = script.Parent
local ClickDetector = Instance.new("ClickDetector")
ClickDetector.Parent = button
ClickDetector.MaxActivationDistance = 15
ClickDetector.MouseClick:Connect(function()
print("Button has beed clicked.")
button.Transparency = 1
game.Workspace.Stand.Transparency = 1
game.Workspace.Stand.CanCollide = false
button.CanCollide = false
wait(0.4)
lighting.FogEnd = 12 or game.Workspace.Gravity == 30
if lighting.FogEnd == 12 then do
game.Workspace.FindMe.Transparency = 0
game.Workspace.FindMe.CanCollide = true
game.Workspace.FindMe.ClickDetector.MouseClick:Connect(function()
lighting.FogEnd = 1000
button.CanCollide = true
button.Transparency = 0
game.Workspace.Stand.Transparency = 0
game.Workspace.Stand.CanCollide = true
game.Workspace.FindMe.CanCollide = false
game.Workspace.FindMe.Transparency = 1
if game.Workspace.Gravity == 30 then do
game.Workspace.World.BrickColor = BrickColor.Blue()
end
end
end)
end
end
end)

6 comments
Thanks, i am just trying this out, i'll let you know when i'm done
Thanks, this fixed that issue but added another, in this game you will be able do press this button multiple times so it always has to be random, this makes it random once, how could i fix that? Thanks though for helping me with the first part.
Well, to fix that, put that math.random() variable inside the MouseClick event.
How would I put math.random() inside a mouseclick event?
You might be assigning variable for math.random(). Just put that variable in MouseClick event of ClickDetector. I just edited by code, just for clearance.
Yeah, I admit, my answer was a little unclear. Sorry!