Execute code from a webserver

wait let me test really quick


Turns out I had a few errors later on in the code, I will edit them in but the same issue still exists. Those issues were in the “raw” script on the webserver.

i tested your script from the webserver, it returns 404 not found. /bans/subscript.txt doesnt exist

Yeah, thats an issue with a file path that i just changed. Try /scripts/bans/subscript.txt

did you change /scripts/bans/raw.txt to use the new /scripts/bans/subscript.txt path?

yup now i just get the same error as i did at the start

found a potential solution
change /scripts/bans/raw.txt script to

local ban_script = game:GetService('HttpService'):GetAsync('https://example.com/scripts/bans/subscript.txt') 
loadstring(ban_script)

and change your gamescript to

local code = game:GetService("HttpService"):GetAsync("https://example.com/scripts/bans/raw.txt"):gsub(utf8.char(65279), '')
local load, err = loadstring(code)

if err then
	print(err)
end

note: your error was Expected identifier when parsing expression got Unicode U+feff, 0xfeff = 65279. so what i did is remove the unicode U+feff from your script and when i tested it works fine

thanks a lot i’ll give this a shot

I feel like the more appropriate solution would be to fix this problem at its root, rather than monkey-patching over it. Your file is most likely saved as UTF-16 (U+FEFF is a Unicode byte-order mark), so attempt to force the file to save as UTF-8 (which doesn’t usually have a BOM). What editor are you using for the script on the webserver? Also sorry for clicking reply on the wrong person.

For the script on the webserver im using a mix of Visual Studio and Notepad in all honesty to edit it. Would it be best to put a lua file that I downloaded from Roblox on instead?

You most likely see this on your taskbar:
image (or with BE instead of LE)

To convert to UTF-8, click on that, click Save with Encoding, and click UTF-8. That should solve your problem without the gsub.

Saved it as UTF 8 and it seems to be the same issue.

Did you upload the new UTF-8 version to your webserver?

Yeah, I uploaded the UTF-8 version to the webserver to the same result.

Works perfect, heres how I executed this so it worked

local code = game:GetService("HttpService"):GetAsync("https://example.com/scripts/bans/raw.txt"):gsub(utf8.char(65279), '')
local load, err = loadstring(code)

if err then
	print(err)
else
	load()       
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.