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

Help with Gui?

Asked by
FiredDusk 1466 Moderation Voter
8 years ago

I know how to get all parents but when I click on the "Enter" button, it shows the text if its success of a failure in STUDIO mode. If I am in a real server, the text does not come up.

--//Variables
player = game.Players.LocalPlayer
TypeHere = player.PlayerGui.CodeGui.TypeHere
Enter = player.PlayerGui.CodeGui.Enter
Weapon = game.Lighting.Weapon --Whatever name you want the item to be that is in lighting

--//Function
Enter.MouseButton1Click:connect(function()
    if TypeHere.Text == "youtube" then --"youtube" is the code they need to put in so they can get the item in Lighting
        Enter.Text = "Success"
        Weapon.Parent = player.Backpack
    else
        Enter.Text = "Failure"
    end
end)
1
The error is: TypeHere is not a valid member of ScreenGui NeonicPlasma 181 — 8y
1
This was caused on line 3 NeonicPlasma 181 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

TypeHere was the error, as listed by PickUpTheBeat1 in the comments.

To make it work better:

local gui = player.PlayerGui:FindFirstChild("CodeGui")
local TypeHere = nil
if gui then
    TypeHere = gui:FindFirstChild("TypeHere")
end

Enter.MouseButton1Click:connect(function()
    if TypeHere then
        if TypeHere.Text == "youtube" then
            --code
        end
    end
end)

Also, if there's an error in the output about something being nil (and that something isn't nil, and you have done everything right), a change of search can fix it. E.g:

game.Workspace -- doesn't work
game["Workspace"] -- works
0
Where are other variables? FiredDusk 1466 — 8y
0
This is an answer, not request site. I answered your question, I din't need to put in the variables. That script was an example (that you can copy) TheDeadlyPanther 2460 — 8y
0
I never requested. I asked you and you never answered.. FiredDusk 1466 — 8y
0
This is simply meant as a demonstration, I don't need the variables. Sorry if you interpreted wrong. TheDeadlyPanther 2460 — 8y
Ad

Answer this question