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

How to make a text in a textbutton preform a function?

Asked by 5 years ago

--I've been trying to get a GUI textbox to do something when it has a certain text

--CODEN is a ScreenGUI, VERIFICATION is a frame and ENTERHERE is a textbox

--IAMLOCKED is a part within the workspace

--this is the script:

local plr=game.Players.LocalPlayer

local code=plr.PlayerGui.CODEN.VERIFICATION.ENTERHERE.Text

if code=='ohhellothere' then game.Workspace.IAMLOCKED.CanCollide=false end

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

This does not work since the if statement only ran once. The code is not under an event or loop. Here is your code. It also doesn’t work since you set the code variable to the box’s Text, which only sets the variable to the current text at assigning the variable. Instead, set the variable to the object and set the .Text later on.

loca plr = game:GetService('Players').LocalPlayer
local plrGui = plr:WaitForChild'PlayerGui'

local codeBox = plrGui.CODEN.VERIFICARION.ENTERHERE

codeBox:GetPropertyChangedSignal('Text'):Connect(function() 
    if codeBox.Text == 'ohhellothere' then
        game.Workspace.IAMLOCKED.CanCollide = false
    end
end)
Ad

Answer this question