Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Heya! I need a chance script using promixity prompts and guis. anyone can help me?

Asked by 3 years ago

I'm currently making a game and I wanna make it so if you finish the promixity prompt a gui will appear and i want a chance to get 3 endings Good ending (49%), Bad ending (49%), and the secret ending (2%) the numbers are the rarity to each ending (duh) and I really want this to work commenting with a script would help alot!

0
i dont really know scripting so helping me with this would help alot TheModdedFox 0 — 3y
0
use math.random(). example: math.random(1, 3), the "1, 3" means the chance of it happening vendinY 5 — 3y
0
ohh ok TheModdedFox 0 — 3y
0
thanks but how do i make the guis to pop up? and how will i make music play if the promixity prompt is finished? TheModdedFox 0 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

using math.random() will do, here's the example of the script:

local chance = math.random(1, 2) 

if chance == 2 then --// If chance's value is 2 then it will print "2"
    print("2")
elseif chance == 1 then --// Else if chance's value is 1 then it will print "1"
    print("1")
end

To make this work with proximity prompt, use ProximityPrompt.Triggered

script.Parent.Triggered:Connect(function() 
    local chance = math.random(1, 2)

    if chance == 1 then
        print("1")
    elseif chance == 2 then
        print("2")
    end
end)

to play the sound, simply just use Sound:Play(), to make the gui pop up, use GUI.Visible = true

comment if you have questions

Ad

Answer this question