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

What's wrong with my script that edits a ScreenGui?

Asked by 10 years ago

Currently I'm trying to edit the text inside of the Player's PlayerGui, and the only error that APPEARS to be connected to this script is "TextBounds is not a member" or something like that. The thing is nothing in my script messes with TextBounds. The hierarchical structure of my variables are correct. Here's my script:

wait(1)

A = script.Parent.Parent.Parent.PlayerGui.ChooseFoot.CFF.CF

function ChangeFeet(CF)
    if CF == Enum.KeyCode.LeftAlt then
        if A.Text == ("R") then
            A.Text = ("L")
        elseif A.Text == ("L") then
            A.Text = ("R")  
        end
    end
end

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

1 answer

Log in to vote
1
Answered by 10 years ago

InputBegan returns an InputObject that has the property KeyCode. I see that you used it in your print statement. Also I would recommend using localplayer for locating the gui.

A = Game.Players.LocalPlayer.PlayerGui.ChooseFoot.CFF.CF

function ChangeFeet(CF)
    if CF.KeyCode == Enum.KeyCode.LeftAlt then
        if A.Text == ("R") then
            A.Text = ("L")
        elseif A.Text == ("L") then
            A.Text = ("R")  
        end
    end
end

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

0
Thanks, it worked when I added the CF.KeyCode part of the script. Ghost4Man 25 — 10y
Ad

Answer this question