So I have a GUI with a local script that allows the GUI to toggle when the key is pressed.
local var = "k"
game.Players.LocalPlayer:GetMouse().KeyDown:Connect(function(KeyPressed)
if KeyPressed == var then
if script.Parent.Main.Visible == false then
script.Parent.Main.Visible = true
else
script.Parent.Main.Visible = false
end
end
end)
But my GUI also has a settings tab. The settings tab contains a textbox in which I would like to set the toggle key.
Code of the textbox:
TextBox.FocusLost:Connect(function(enterPressed, inputThatCausedFocusLost)
if enterPressed then
script.Parent.Parent.Parent.LocalScript:howwouldIaccessthevairiable
else
print("Player pressed", inputThatCausedFocusLost.KeyCode)
end
end)
I would like to know how I can set the value of "var" to whatever the value of the textbox is. Yes I know I could just make the toggle script child of the textbox instead of a child of the ScreenGui but I have other needs where that wouldn't work.
Image:

1 comment
this is assuming "script.Parent.Parent.Parent.LocalScript" is the script with the variable you want to change