So, I have to make a script where it will randomly decide which function will be called, but for some reason it will only call the function that has to be called if 1 will be chosen by math.random, and functions under other numbers will not call the function or any other action, and instead just skip it onto next lines.
The code is:
local values = game.Workspace.MetroMap.Part1.Area2.Values
local sa1p = game.Workspace.MetroMap.Part1.Area2.TouchParts.ShopArea1Part
local light = script.Parent.SurfaceLight
local angle = light.Angle
local neon = script.Parent
local anglevalue = script.Parent.SurfaceLight.AngleNum.Value
local function disable()
neon.Material = Enum.Material.SmoothPlastic
light.Enabled = false
light.Angle = 0
sa1p.LampsSound2:Stop()
end
local function enable()
local mr1 = math.random(1,3)
local function enable1()
sa1p.LampsSound2:Play()
neon.Material = Enum.Material.Neon
light.Enabled = true
light.Angle = 22.5
end
local function enable2()
sa1p.LampsSound1:Play()
local function angletween()
local tw = game:GetService("TweenService")
local twi = TweenInfo.new(
2,
Enum.EasingStyle.Back
)
local angletw = tw:Create(light, twi, {Angle = anglevalue})
angletw:Play()
end
neon.Material = Enum.Material.Neon
light.Enabled = true
angletween()
end
local function rng1()
enable1()
wait(0.15)
disable()
wait(0.15)
end
local function rng2()
enable1()
wait(0.25)
disable()
wait(0.15)
end
local function rng3()
enable1()
wait(0.5)
disable()
wait(0.15)
end
local function rngenable()
if mr1 == 1 then rng1()
if mr1 == 2 then rng2()
if mr1 == 3 then rng3()
end
end
end
end
rngenable()
enable2()
end
values.A1Lamp1Power.Changed:Connect(function(Value)
if Value == true then
enable()
else
disable()
end
end)
What I need is functions to be called if number other than 1 will be chosen.