I am making a script where if you type "hello" and press enter in a text box, it undisables a script that adds 5 coins to a coins datastore. Here is the script that undisables the script: note: the script is in the workspace
game:GetService("UserInputService").InputBegan:Connect(function(key) if key.KeyCode == Enum.KeyCode.Return then if script.Parent.Text == "hello" then print("worked") workspace.dsactivatecoins5.Disabled = false local particalsuccess = Instance.new("ParticleEmitter") particalsuccess.Parent = game.workspace.tvscreencpp particalsuccess.Name = "particle" particalsuccess.Enabled = true script.Parent.Parent.Frame.text.Text = "Great job! Now click the button that says 'teleport to example' Also, here are some coins!." script.Parent.Parent.TextButton.Visible = true wait(2) particalsuccess.Enabled = false script.Parent.Parent.yaycorrect.Visible = false script.Parent.TextEditable = false script.Disabled = true end if script.Parent.Text ~= "hello" then print("DENIED") local udidbad = Instance.new("Explosion") udidbad.Name = "bad" udidbad.Parent = workspace.tvscreencpp script.Parent.Parent["no :("].Visible = true udidbad.Position = workspace.tvscreencpp.Position udidbad.BlastRadius = 20 wait(2) udidbad:Destroy() script.Parent.Parent["no :("].Visible = false end end end)
Use this function instead:
[textBox].FocusLost:Connect(function(enterPressed) if enterPressed then --checks that enter was pressed. --Insert your code here. end end)
It turns out that it is the script that is not functioning. i have tried using attributes, but I do not know how to use if statements with them