function unselect()
local children = script.Parent:GetChildren()
for i = 1,#children do
if children[i].ClassName == "ImageButton" and children[i].Chosen.Value == true then
print("Unselected " .. children[i].Name)
children[i].Chosen.Value = false
children[i].BorderSizePixel = 2
children[i].BorderColor3 = Color3.fromRGB(35,35,35)
children[i]:TweenSize(UDim2.new(0, 80, 0, 80), "In", "Quad", .2)
end
end
end
function pselect(pokeID)
local clicked = pokeID.Parent.Parent
script.Parent.PokemonID.Value = pokeID
unselect()
clicked.Chosen.Value = true
clicked.BorderSizePixel = 3
clicked.BorderColor3 = Color3.fromRGB(57,141,230)
clicked:TweenSize(UDim2.new(0, 90, 0, 90), "Out", "Quad", .2)
print(pokeID)
print(clicked.NameLabel.Text)
end
script.Parent.P151.MouseButton1Click:connect(pselect(script.Parent.P151.PokemonID.Value))
There's a bit of extra code there, but I figured you need to see it all, just in case. The problem is occurring on line 15,
local clicked = pokeID.Parent.Parent
The error message I get is:
Players.pokemon_origin.PlayerGui.ScreenGui.PokemonList.LocalScript:19: attempt to index local 'pokeID' (a number value)
The value I'm passing is an integer, it's just 151. The error seems to be in the passing of the value, because it gives an error the first time my script tries to use the passed value (151). If I missed out any information, please ask. Thanks.
EDIT: It clipped off the last line of the code, here it is: script.Parent.P151.MouseButton1Click :connect(pselect(script.Parent.P151.PokemonID.Value))

1 comment
Thank you so much, I recall getting errors that complained I didn't pass a function, but I had no idea how one would even go about passing a function. A+ for you, good sir. Thanks!