Hello, I would like to create an inventory of skins of an item using crates in a game, however, I am unable to find an instance from a value, and any solutions I have tried (mainly from the devforum) have not worked. I have attempted to use different string and data table messages but it seems everything I attempt to find does not work. The script breaks at around line 27 and I would like to have a fix for it.
Here is the current code I have (ignore the tweens)
local gui = script.Parent.Parent.Parent.Parent
local ts = game:GetService("TweenService")
local growinfo = TweenInfo.new(2,Enum.EasingStyle.Quad,Enum.EasingDirection.Out,0,false,0)
local explodeinfo = TweenInfo.new(2,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0,false,0)
local coverscreeninfo = TweenInfo.new(2,Enum.EasingStyle.Quart,Enum.EasingDirection.In,0,true,0)
local itemnames = {
"Red",
"Orange",
"Yellow",
"Green",
"Blue"
}
local growtween = ts:Create(gui.SkinCrateImage, growinfo, {Size = gui.SCIReference.Size})
local explosiontween = ts:Create(gui.ExplodeImage, explodeinfo, {Size = gui.EXIReference.Size;Rotation = gui.EXIReference.Rotation})
local coverscreentween = ts:Create(gui.CoverScreen, coverscreeninfo, {BackgroundTransparency = 0})
function leftClick()
growtween:Play()
wait(0.3)
explosiontween:Play()
wait(0.4)
coverscreentween:Play()
wait(2)
local currentitem = itemnames[math.random(#itemnames)]
local TargetString = tostring(itemnames)
gui.OwnedSkinGui.TargetString.BackgroundColor3 = Color3.fromRGB(134, 134, 134)
gui.Example.Text = currentitem
gui.ExplodeImage.Size = UDim2.new(0, 1, 0, 1)
gui.SkinCrateImage.Size = UDim2.new(0, 1, 0, 1)
end
script.Parent.MouseButton1Click:Connect(leftClick)
Each item in the list has a corresponding TextButton with the same name. Thank you!
(BTW I know this is possible with a bunch of if statements but I would like to keep the code clean.)