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

Why doesn't my keypad screen gui script work properly?

Asked by
LawlR 182
5 years ago
Buttons[1].MouseButton1Down:Connect(function()
    Screen.Text = Screen.Text:gsub('-','')
    print(Screen.Text)
end)

This adds 1 to the screen, but for some reason it adds it to the start of the code. For example, if 123 is already on the screen, it would make it 1123, instead of 1231 like I want it to. I'm not sure how to properly use gsub and would appreciate some help. There's also a "-" already on the screen from the start because without it, the 1 doesn't get added for some reason.

0
The second parameter should be LawlR 182 — 5y
0
Percent11 LawlR 182 — 5y

1 answer

Log in to vote
1
Answered by
PolyyDev 214 Moderation Voter
5 years ago

Have you tried concatenation?

Buttons[1].MouseButton1Down:Connect(function()
    Screen.Text = Screen.Text .. "1"
    print(Screen.Text)
end)

That just adds the number to the end of the string.

Accept and up vote if this helped (I need 1 up vote)

0
Yes, that was the first thing that I tried however it didn't work. I tried it again nonetheless and it worked. I'm not sure why it didn't work before but thanks for your answer. LawlR 182 — 5y
Ad

Answer this question