Screen sharing in Roblox

I don’t unfortunately. I used some weird Websocket Proxy module to connect to a server that sends pixel info in JSON format. It wasn’t in python. It was in JS. But I do have the client side which I run on my PC to send images to the server for it process them.

try using localhost first to see if there is a problem with port forwarding

Here is an example of what it looks like playing a video from mrbeast:
image

7 Likes

Yeah i tried, it works in studio but not in game. This is the script, why won’t it work? I even made one which retries connection.

http = game:GetService(“HttpService”)

function GetPixels()
local message = “request pixels”
http:PostAsync(“http://MyIp:80/test”, message,Enum.HttpContentType.ApplicationUrlEncoded)
local data = http:GetAsync(“http://MyIp:80/test”)
return http:JSONDecode(data)
end

and my displaying part of script seems to not get full 8 capped frames, idk why. Is there room for improvement or do i need to redesign the whole structure?

while RunService.Heartbeat:Wait() do
colors = GetPixels()
for c = 1, Sizex * Sizey do
pixels[c].Color = Color3.fromRGB(tonumber(colors[c][1]), tonumber(colors[c][2]), tonumber(colors[c][3]))
end
end

There might be an error with your http request. I recommend you try without your auto-retry http request.

yeah i tried and it says there is http error but it doesnt say it in studio and in studio it works

There is maybe an issue with your IP port or router configuration. I won’t show you how to configure it since I have no idea. Personally, I would use some service like ngrok to host your web app from your localhost.

i recommend playit.gg because it offers a lot more than ngrok

1 Like

well now i think it connected but it says request denied, i will try playit.gg as icy said

I have optimized my code to the maximum. It now takes maximum 1 millisecond to draw on the screen a frame.

well now it works! Finally! But the framerate… Do you have any tips to optimize my loop that i shared in before comment? Or maybe should i take another direction?

I can tell you that indexing tables or simply using global variables takes quite a lot of time so before the script starts you can declare the ones that use the most memory in a local variable. For example, the Color3.fromRGB may take some time. so you can do something like this

local Color3_fromRGB = Color3.fromRGB

-- your loop here with the updated reference to the Color3.fromRGB

You could also do the same with how you index the colors in RGB like so:

local color = colors[c]

color[1] -- Red
color[2] -- Green
color[3] -- Blue

and i am a pretty script noob, do you have any idea why i am not reaching over 500 htpp requests? Is that becuase my for loop is so slow so i dont even need a cooldown for it?

You shouldn’t reach 500 requests per minute. The 500 requests per minute only works when the game is starting up after that it drops down to 20 per second. Maybe the image file the server is downloading takes lot of time but there’s nothing you could do about it I think.

Edit: Just reread my post and it makes no sense. Ignore it.

My way I did it is:

  1. Parse the images on the server.
  2. Send the parsed images to the client for render.
  3. Render them

This is insanity. This is actually cool. Good job.

please just use an http tunnel

local Color3_fromRGB = Color3.fromRGB

Hey this won’t increase speed at all, it will actually make it worst. This only applies for lua not luau, you can do your own tests and you won’t find much of a difference

1 Like