I want this button to work only if the script's parent's child, "PackTitle", has the text "Peak Performance Pack." Would I put an if statement before it?
if script.Parent.Parent.PackTitle.Text == "Peak Performance Pack" then
And would this be added right after (with another end of course)?
Table1={"262077956","262077680","262077809"} function onButtonClick1() local Picked=Table1[math.random(1,#Table1)] script.Parent.Parent.Parent.Parent.NewItemsFrame.Card1.Image ="rbxassetid://"..Picked end
That is totally correct; difference is that you said that it was the script's parent's child. Which means:
script.Parent.PackTitle
What you wrote:
script.Parent.Parent.PackTitle
That means it's the script's parent's parent's child.
You also did not call the function when the button is clicked.
Full script:
Table1={"262077956","262077680","262077809"} local button = script.Parent -- change it to the text button that does this when it's clicked function onButtonClick1() if script.Parent.PackTitle.Text == "Peak Performance Pack" then local Picked=Table1[math.random(1,#Table1)] script.Parent.Parent.Parent.Parent.NewItemsFrame.Card1.Image ="rbxassetid://"..Picked end end button.MouseButton1Click:connect(onButtonClick1) -- calling the function when it is clicked
Hope it helps!