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

The error is 'attempt to perform arithmetic (add) on string'?

Asked by 3 years ago
local text = script.Parent.Parent.ComputerScreen.SurfaceGui.TextLabel
script.Parent.ClickDetector.MouseClick:Connect(function()
    text.Text = text.Text + "H"
end)

this is my script. I dont know whats wrong.

1 answer

Log in to vote
2
Answered by
raid6n 2196 Moderation Voter Community Moderator
3 years ago
Edited 3 years ago

You cannot add a string and string, only number and a number, instead use this:

text.Text = text.Text.."H"

How it works: Ever time to click, it will change the text to the text, but with an added letter.

Example: The text is "H", after clicking, it will become, "HH"

Backspace:

if #text.Text >= 1 then
    script.Parent.Text = script.Parent.Text:sub(1, (#text.Text - 1))
end
Ad

Answer this question