I have a mirror in game that when interacted with a proximity prompt, will enable a GUI imagelabel on a player’s screen. I have two verisions of this GUI decal, one normal one and one not normal one. I want to make it a something in x chance or x% chance of the not normal decal enabling rather than the normal GUI but I have limited knowledge in scripting alone and am completely new to introducing chance in a script.
How would I make it so there is a let’s say, 10% chance/1 in 10 chance of the not normal GUI showing up? Would I need to use something like a chance list?
I have tried using a chance list but I guess I’m doing something wrong because then it breaks the entire script. I think my issue is that I’m getting confused with making sure that the GUI that shows up and goes away when the proximity prompt is interacted with.
This is the current script I have that enables the normal decal GUI, it doesn’t include anything to do with the not normal decal:
local proximity = workspace.MirrorPrompt.ProximityPrompt -- the proximity prompt itself in workplace
local ProximityPromptService = game:GetService("ProximityPromptService")
proximity.Triggered:Connect(function()
local GUI = script.Parent:WaitForChild("MirrorNormal") -- normal mirror GUI
GUI.Enabled = not GUI.Enabled
end)
local GUI = script.Parent:WaitForChild("MirrorNormal")
GUI.Frame.TextButton.Activated:Connect(function()
GUI.Enabled = not GUI.Enabled
end)
Is this how I would apply it? Tried this script but it didn’t work for me.
local proximity = workspace.MirrorPrompt.ProximityPrompt -- the proximity prompt itself in workplace
local ProximityPromptService = game:GetService("ProximityPromptService")
if math.random(1, 2) == 1 then -- I set it to 1, 2 just to test if it's working
proximity.Triggered:Connect(function()
local GUI = script.Parent:WaitForChild("MirrorNormal") -- normal mirror GUI
GUI.Enabled = not GUI.Enabled
end)
local GUI = script.Parent:WaitForChild("MirrorNormal")
GUI.Frame.TextButton.Activated:Connect(function()
GUI.Enabled = not GUI.Enabled
end)
elseif math.random(1, 2) == 2 then
proximity.Triggered:Connect(function()
local GUI = script.Parent:WaitForChild("MirrorNotNormal") -- not normal mirror GUI
GUI.Enabled = not GUI.Enabled
end)
local GUI = script.Parent:WaitForChild("MirrorNotNormal")
GUI.Frame.TextButton.Activated:Connect(function()
GUI.Enabled = not GUI.Enabled
end)
end
Names = {"MirrorNormal", "MirrorNotNormal"} -- Names
local random = Names[math.random(1, #Names)] -- random Number by Number of index keys to get a Name
script.Parent[random].Enabled = not script.Parent[random].Enabled -- Enables based on Name