Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
1

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

Asked by
RareBIue 128
13 days 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 2121 Moderation Voter Community Moderator
13 days ago
Edited 12 days 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