edit: fixed read last comment
I've looked at other questions similar to mine asked on this site, in fact that's what brought me here to ask instead of the Robloxforum. The general fix to the issue of scripts/guis not working in-game when they appear to work in studio is to use the F9 console, or dev console in-game to try and figure out the bug.
In my case, I can't see anything on the console in-game, as if my code isn't being picked up at ALL when loaded into the Roblox game.
Here is my code, it's been put in a Local Script and a normal Script with no difference in-game. I know it's extremely ineffective coding, but Roblox seems to have deprecated most of the features I used before taking a break.
TL;DR, Title - f9 console doesn't show anything
print("test") PID = script.Parent.PokemonID.Value 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 script.Parent.P1.MouseButton1Click:connect(function() clicked = script.Parent.P1 PID = clicked.PokemonID.Value 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(PID) print(clicked.NameLabel.Text) end) script.Parent.P4.MouseButton1Click:connect(function() clicked = script.Parent.P4 PID = clicked.PokemonID.Value 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(PID) print(clicked.NameLabel.Text) end) script.Parent.P7.MouseButton1Click:connect(function() clicked = script.Parent.P7 PID = clicked.PokemonID.Value 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(PID) print(clicked.NameLabel.Text) end) script.Parent.P25.MouseButton1Click:connect(function() clicked = script.Parent.P25 PID = clicked.PokemonID.Value 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(PID) print(clicked.NameLabel.Text) end)
Thanks.
The studio test runs differently than actual servers! I've dealt with this problem multiple times, and you will need to run a server to see how the script actually works in game. Hopefully that helps you with your problem!
Add a wait(0.5) to the top of the script.
You are defining PokemonID way too earlier in the script
You have to remember that studio renders scripts faster compared to a server.