I am making an reactor core game making a chance system for core to start and fail start

I need help making this chance system

Script:

local function onclick(CLICKED)

local failstart = 100
local start = 5
local result = math.random(0,100)

if result <= failstart then

core.FailStart.Enabled = true
core.FailStart2.Enabled = true

elseif result <= start then

core.Beam.Enabled = true

      end

end

click.MouseClick:Connect(onclick)

and they dont work
Reply to me if you have an solution

1 Like

Have you tried any debugging? (Ex: Prints)

Also, what exactly are the chances?

Is it 5% to start and 95% to fail? Please elaborate.

i have tried but it didnt work.

also 100% of fail startup and 5% of the startup completion

if startup completion complete it will make the laser beam enabled.

if fail startup 2 beam will activate

REMINDER: THIS SCRIPT IS WIP.

local function onclick(CLICKED)
    -- Define the probability thresholds
    local failstartChance = 100
    local beamChance = 5
    
    -- Generate a random number between 1 and 100
    local result = math.random(1, 100)

    if result <= beamChance then
        -- This means there's a chance to enable the Beam
        core.Beam.Enabled = true
    elseif result <= failstartChance then
        -- This means there's a chance to enable FailStart and FailStart2
        core.FailStart.Enabled = true
        core.FailStart2.Enabled = true
    end
end

click.MouseClick:Connect(onclick)
1 Like

ill try this thank you for the script.

2 Likes

i will mark this solution if the script works.

works thank you!

for the script!

marked as solution.

1 Like

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