Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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)

1 comment

0

Thanks, it worked when I added the CF.KeyCode part of the script.

This discussion is preserved as it was. New answers, comments, and votes are closed.