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

How to edit a ScreenGui? Everything I've tried will not work

Asked by 9 years ago

I've tried everything in making this script work and nothing fixes it. I've tried changing the text in the TextLabel, when that didn't work I did what I do now in having two separate TextLabels and just setting the visibility boolean to true/false. I've made sure the "file" paths check out as well. This is getting extremely frustrating

local CFR = game.StarterGui.ChooseFoot.Frame.R
local CFL = game.StarterGui.ChooseFoot.Frame.L

function Pressed(key)
        if key == Enum.KeyCode.LeftAlt then
            if CFR.Visible == true then
                CFR.Visible = false
                CFL.Visible = true
            elseif CFR.Visible == false then
                CFR.Visible = true
                CFL.Visible = false
            end
        end
end

game:GetService("UserInputService").InputBegan:connect(Pressed)

1 answer

Log in to vote
0
Answered by 9 years ago

You are going to want to use a LocalScript in order to edit GUIs for specific players. You can access their GUIs through PlayerGui, otherwise, editing the StarterGui will not cause any change until they respawn.

Here is what your script should be placed in a LocalScript within the StarterGui. If this does not work then there is something wrong with your script or your hierarchical structure.

wait(1) -- assets need time to load
player = game.Players.LocalPlayer
gui = player.PlayerGui.Choosefont
CFR = gui.Frame.R
CFL = gui.Frame.L

function Pressed(key)
        if key == Enum.KeyCode.LeftAlt then
            if CFR.Visible == true then
                CFR.Visible = false
                CFL.Visible = true
            elseif CFR.Visible == false then
                CFR.Visible = true
                CFL.Visible = false
            end
        end
end

game:GetService("UserInputService").InputBegan:connect(Pressed)

Ad

Answer this question