I’m trying to make this computer thing where you press buttons and it inputs a letter, but how would i make a backspace button where it removes the last letter you typed?
I have no clue what you mean could you be a bit more precised
Normally, when you press “Backspace” it removes a letter like when you typed something but you misstyped you remove it just to make it better…
Please show us the script/image.
So i have this thing, where you collect letters and you put them in. you can only put in letters you have. How would i make it so when you press on another backspace button and it would remove the last letter you clicked on it, and it gives the last letter back to you?
Hopefully this is more precise
local CurrentText = TextBox.Text -- This is the Text Typed
local ShortenedText = string.sub(CurrentText,1,#CurrentText-1) -- We Removed Last Letter
TextBox.Text = ShortenedText -- Sets the Text To the Text Entered, But one Less
-- The Shortened Text is the Text With the Last Letter Removed
You can Combine this Script with Your System,
Just Detect when the Player Pressed Backspace And then Remove the Last Letter Like in the script above.
Oh okay I know what you mean now.
game:GetService("UserInputService").InputBegan:Connect(function(gp, typing)
if typing then return end
if input.KeyCode == Enum.KeyCode.Backspace then
-- Removes previous letter
end
end)
For me to remove the previous letter, please show me the script to add one.
I have a script in every seperate button, all of them look like this:
local TextBox = script.Parent.Parent.TextBox
function onClick(click)
local inv = click.PlayerGui.Letters.Frame
local letter = script.Parent.Name
if inv[letter].Amount.Value.Value >= 1 then
TextBox.SurfaceGui.Frame.TextLabel.Text = TextBox.SurfaceGui.Frame.TextLabel.Text..letter
inv[letter].Amount.Value.Value = inv[letter].Amount.Value.Value - 1
end
end
script.Parent.ClickDetector.MouseClick:connect(onClick)
I’m sorry but i dont know how to correctly put the script in
can you show the script which is currently inside the backspace button?
local CurrentText = TextBox.Text
local ShortenedText = string.sub(CurrentText,1,#CurrentText-1)
TextBox.Text = ShortenedText
function onClick(click)
TextBox.Text = ShortenedText
end
script.Parent.ClickDetector.MouseClick:connect(onClick)
function onClick(click)
local CurrentText = TextBox.Text
local ShortenedText = string.sub(CurrentText,1,#CurrentText-1)
TextBox.Text = ShortenedText
end
script.Parent.ClickDetector.MouseClick:Connect(onClick)
try this
I’m not helping him, i’m just saying to do his best to make the “Backspace” button.
This works, it now removes the last letter in the box, but how would i make it so it gives you the letter back?
I figured out a solution myself, thanks to your help!
local TextBox = script.Parent.Parent.TextBox
function onClick(click)
local inv = click.PlayerGui.Letters.Frame
local CurrentText = TextBox.SurfaceGui.Frame.TextLabel.Text
local ShortenedText = string.sub(CurrentText,1,#CurrentText-1)
local letter = string.sub(CurrentText, #CurrentText)
TextBox.SurfaceGui.Frame.TextLabel.Text = ShortenedText
inv[letter].Amount.Value.Value = inv[letter].Amount.Value.Value + 1
end
script.Parent.ClickDetector.MouseClick:Connect(onClick)
This is the final script, and it works.
Nice, it’s really good for you, i knew that’s gonna work.
Also keep up the good work !