Pardon the confusing title, I really had no idea how to go about wording it. So, I am making this fun little machine that will give random images from my clan’s history when the lever is pulled. I managed to get it to give a random image every time the lever is pulled (it surprisingly worked my first time), but I am absolutely stumped as to how to solve the problem.
I wish to give each image a small text on a separate surfaceGUI. The issue is, I have absolutely no idea how to make it so that when it choses a random image, that it will also choose the text that is meant to go along with it. This is my first time scripting with tables, is there a way to make it so that it can randomly pick both the roblox image ID as well as the text I wish to go along with it?
Normally I’d try to come up with some ideas myself, but I’m quite honestly clueless on how to approach this.
The script for the machine:
local Screen1 = script.Parent.Parent.Screen1.SurfaceGui.ImageLabel
local Screen2 = script.Parent.Parent.Screen2.SurfaceGui.TextBox
local Screen3 = script.Parent.Parent.Screen3.SurfaceGui.TextBox
local FEARImages = {"6653345357","6653332249"}
function GetImage()
local randomimage = "http://www.roblox.com/asset/?id="..FEARImages[math.random(1, #FEARImages)]
Screen1.Image = randomimage
end
ClickDetector.MouseClick:Connect(function()
Rotate.Disabled = false
Rotate.Parent.Primary.Sound.Playing = true
Screen3.TextTransparency = 0
Screen3.Parent.Parent.SurfaceLight.Enabled = true
Screen3.Parent.Parent.Computer:Play()
Lever.Orientation = Vector3.new(-90, -135, 0)
ClickDetector.MaxActivationDistance = 1
wait(5)
Rotate.Disabled = true
Rotate.Parent.Primary.Sound.Playing = true
Screen3.TextTransparency = 0.8
Screen3.Parent.Parent.SurfaceLight.Enabled = false
Lever.Orientation = Vector3.new(-45, -45, -90)
Screen2.Text = "Enjoy your image!"
GetImage()
Screen3.Parent.Parent.Tada:Play()
wait(2)
Screen2.Text = "AWAITING INPUT"
ClickDetector.MaxActivationDistance = 15
end)
Please ignore my lack of a debounce which was replaced by a change in MaxActivationDistance, I’ve been up for like 20 hours working on this game, lol. I’d be glad to explain more if needed, as I’m probably not being very clear here.