Hey there, I am just getting into scripting and I was trying to make this script where it generates a random number out of 3, then whatever number gets rolled is the outcome, (ex. 1 makes the player die, 2 makes the world shake, 3 does nothing, these are random examples) gives an outcome that is scripted in the same script. The problem is that last night I was proud it was working with my little debug world where the checkmark would light up for the designated number, but now that I’ve modified it, it is showing no errors but is not working at all.
The script won’t even Output the number anymore, does anyone know how I can fix this? Please try not to include slang, keep things basic as any words I don’t understand will just be googled. Thanks!
local randomNumerical = math.random(3)
print(randomNumerical)
if (randomNumerical) == 1 then
game.Workspace.TouchBrick1.Touched:Connect(function(hit)
if hit then
game.Workspace.HallwayLight1.Union.PointLight.Brightness = 0
game.Workspace.HallwayLight.Union.BrickColor = "Black"
end
end)
if (randomNumerical) == 2 then
game.Workspace.TouchBrick1.Touched:Connect(function(hit)
if hit then
game.Workspace.HallwayLight1.Union.PointLight.Brightness = 0
game.Workspace.HallwayLight.Union.BrickColor = "Black"
end
end)
end
if (randomNumerical) == 3 then
game.Workspace.TouchBrick1.Touched:Connect(function(hit)
if hit then
game.Workspace.HallwayLight1.Union.PointLight.Brightness = 0
game.Workspace.HallwayLight.Union.BrickColor = "Black"
end
end)
end
end
image: