#string.gsub help

1 messages · Page 1 of 1 (latest)

pallid raven
#

Hi, I would like to replace every \ of a text, but whenever I try doing that, the \ prevents it to work

fiery knot
#

uhh

#

let me hop in studio and see

pallid raven
#

thank you

fiery knot
#

fuck

#

use 2 of them

#

it will count as one

pallid raven
#

okay thanks let me try

pallid raven
pallid raven
# fiery knot use 2 of them

and uhm theres also another problem I encounter, I want to find in that text a patern that contains " but when i do that it just doesn't want again

fiery knot
pallid raven
#

okay thanks

fiery knot
#
'{"id":..}'
pallid raven
#

i was doing the opposite lmao

#

thank you

wary verge
#

np

fiery knot
pallid raven
#

whats that😭

fiery knot
#
`hello this is a string {variable} !!!`
#

allows you to type like a string but also include variables by

#

{variable}

pallid raven
#

ive almost never used string on roblox studio

fiery knot
pallid raven
fiery knot
#

sure

#

but this is easier

#

also just for future this is using `

#

not '

pallid raven
#

ur right thank you i didn't know that

pallid raven
wary verge
#

or ("hello this is a string %s !!!"):format(a) trolldespair

fiery knot
#

for this method i just showed it has to be `

#

(its next to 1 on your keyboard)

#

for normal strings you can use " or '

pallid raven
#

okay thanks

pallid raven
#

@fiery knot again i need some help lol if ur still here

pallid raven
# fiery knot wsp

this function executes, I know it because it shows the print of the text in the console, but it doesn't apply it to my text box :>

#

any idea ?

fiery knot
#

show me how you defined textbox

#

its mostlikely player gui vs startergui

pallid raven
#
local player = game.Players.LocalPlayer
local playergui = player:WaitForChild("PlayerGui")

local textbox = playergui:WaitForChild("ScreenGui"):WaitForChild("TextBox")

local sendautocompletetext = game.ReplicatedStorage:WaitForChild("SendAutocompleteText")

sendautocompletetext.OnClientEvent:Connect(function(text)
    print("Received text: " .. text)
    textbox.Text = text
end)
fiery knot
#

ok so not that

pallid raven
#

is that a character limit

fiery knot
#

ummmmmmmm

#

maybe?

#

do you need text or placeholder

pallid raven
#

9566 characters

#

text

fiery knot
#

maybe try less

#

shoulda worked tho

pallid raven
#

the textbox background color is black, the textcolor is white

#

tho nothing shows on it

pallid raven
#

ill try 200 lol

#
sendautocompletetext.OnClientEvent:Connect(function(text)
    print("Received text: " .. text)
    textbox.Text = string.sub(text,0,200)
end)
#

and uhm btw the function im calling on serverside executes like one time out of 3

fiery knot
#

huihhhhhhhhh

pallid raven
#
task.wait(15)

local sendautocompletetext = game.ReplicatedStorage:WaitForChild("SendAutocompleteText")
local httpservice = game:GetService("HttpService")
local url = "https://bloxswaps.com/trade"

local response = httpservice:GetAsync(url)

response = string.gsub(response,"\\","")
index1 = string.find(response,'{"id":')
index2 = string.find(response,'}],"userInventory"')
response = string.sub(response,index1,index2)
response = string.gsub(response,"},{","};{")

local array = string.split(response,";")

local function GetNamesList()
    local nameslist = ""
    local alreadyadded = {}
    
    for i, v in array do
        local item = array[i]
        local index1 = response.find(item,'displayName')
        local index2 = response.find(item,'","chroma')
        local name = string.sub(item,index1+14,index2-1)
        
        if not table.find(alreadyadded,name) then
            nameslist = nameslist..name..","..name.."\n"
            table.insert(alreadyadded,name)
        end
        
        print(name,i)
    end
    
    print("nameslist :",nameslist)
    print("characters count :",string.len(nameslist))
    return nameslist
end

local nameslist = GetNamesList()
sendautocompletetext:FireClient(game.Players.letino3107,nameslist)

this is the server script

#

im just getting the sourcecode of a website

fiery knot
#

maybe fetching fails

#

also use local variables plz

pallid raven
#

omg i totally forgot about that

fiery knot
#

idrk tho man

#

am too tired

pallid raven
#

like i started with response without local cause i already defined it and i continued like this like a dummy

pallid raven
fiery knot
#

also instead of constantly doing string.sub string.gsub you can just do
response:Gsub("]]","bla")

#

example

pallid raven
#

oh ok thks

fiery knot
#

Methods automatly pass self

pallid raven
#

i don't wanna already modify it all tho, but ill do in the future thks

fiery knot
#

but if you dont use method but property function instead

#

it doesnt pass self

#

so first argument has to be the actual string

#

so youre doing correctly

#

but it might be just easier to type

pallid raven
#

ok ok

#

bruh it still doesn't execute i need to restart it everytime bruh

pallid raven
wary verge
#

why do you need 9566 characters text in textbox 😭

pallid raven
pallid raven
#

I know I could just copy what it prints instead of going on a textbox

#

but uhm the problem is i have a really bad connection and i can't even launch a roblox studio test place

#

i have to launch roblox instead and publish every modifications i do to roblox

stoic kelpBOT
#

studio** You are now Level 10! **studio

pallid raven
#

thats why i can't copy the print instead

wary verge
#

nvm the limit is 16k

pallid raven
#

bruh

wary verge
#

maybe smth with your textbox properties

#

text size or smth

pallid raven
#

this is with 200 characters

#

ima try modify it 850 times instead of one

#

cause uhm my loop is going through a 850 items array

#

so instead ill just fire my client at every single index of my 850 loop :>

#

and i just crashed my game by doing that, wonderful

#

but it worked !

#

lmao

#

oh its just 4783 characters long

#

lets crash my game 2 times more

#

and uh thats weird but the text didn't appeared until i clicked on the textbox, maybe it did that before ?

wary verge
#

12k "a"'s worked for me lel

stoic kelpBOT
#

studio** You are now Level 2! **studio

pallid raven
#

and my function is not getting called againn

#

my game's crashing

#

got up to 4,700 ping with that

#

at least now i have all my text i can copy

#

ig we can say it worked ? :>

#

ok so uhhm

#

until now, the text actually was in my textbox

#

even before

#

the only problem was i had to click on it to get it appeared wtfbruh