Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

My code works in studio test but not in-game? F9 console is blank

Asked by 7 years ago
Edited 7 years ago

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.

0
That looks impossible to read. How do I make it look like code? pokemon_origin 20 — 7y
0
Ah god. The problem was with my team-create stupidity. I have to close a script in order for it to update with the rest of the game. Sorry for your time, scripting helpers. pokemon_origin 20 — 7y

3 answers

Log in to vote
0
Answered by 7 years ago

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!

Ad
Log in to vote
0
Answered by
Silicti 40
7 years ago

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.

Log in to vote
0
Answered by 7 years ago

Yeah, Silicti is right

Answer this question