Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

My module was working days ago, but Roblox broke it, how do I fix it?

The module was working days ago but roblox then broke it when i just changed the HTTP link (because everytime I restart the server, it gives me a new link.) ModuleScript was required from serverside script.

local module = {}
function main()
	p = Instance.new("Part")
	p.Parent = workspace
	p.Size = Vector3.new(13.66, 7.68, 1)
	p.BottomSurface = Enum.SurfaceType.Smooth
	p.BrickColor = BrickColor.new("Institutional white")
	p.Material = Enum.Material.SmoothPlastic
	p.TopSurface = Enum.SurfaceType.Smooth
	p.Transparency = 1
	p.Massless = true
	p.Anchored = true
	p.CanCollide = true
	p.CastShadow = false
	p.Locked = true

	local offset = Vector3.new(59, 3, 47.5)

	local http = game:GetService("HttpService")

	local w,h = 0,0
	local t = 0
	local t2 = 0
	local clearing = false

	local pixels = {}
	local web = 'https://d4bcb1914690.ngrok.io/'
	local fps = 60
	local time_interval = 1/fps/3
	local last_time = tick()
	local mt = 500

	function swait(mode)
		t = t + 1
		if t >= mt then
			t = 0
			game:GetService("RunService").Heartbeat:Wait()
			t2 = t2 + 1
			if mode == 1 and t2 >= 5 then
				wait(0.2)
			end
		end
	end

	function clear()
		clearing = true
		for i,v in pairs(p:GetChildren()) do
			v:Destroy()
			swait(1)
		end
		wait(2)
		clearing = false
	end

	function hex2rgb(hex)
		--hex = hex:gsub("#","")
		local r = tonumber("0x"..hex:sub(1,2))
		local g = tonumber("0x"..hex:sub(3,4))
		local b = tonumber("0x"..hex:sub(5,6))
		return Color3.fromRGB(r,g,b)
	end

	local hex2bgr= function(hex)
		--hex = hex:gsub("#","")
		local r = tonumber("0x"..hex:sub(1,2))
		local g = tonumber("0x"..hex:sub(3,4))
		local b = tonumber("0x"..hex:sub(5,6))
		return Color3.fromRGB(b,g,r)
	end

	local fix_size = function(l)
		local ns
		local success = pcall(function()
			ns = http:JSONDecode(http:GetAsync(web .. "size.json"))
		end)
		if success and ns and ns[1] and ns[2] and (w ~= ns[1] or h ~= ns[2]) and not clearing then
			w = ns[1]
			h = ns[2]
			local d = 5 -- change this for bigger or smaller screen
			local s1,s2 = w/d/w,h/d/h
			p.Position = offset+Vector3.new(0,h/d/2+3,0)
			p.Size = Vector3.new(w/d,h/d,1)
			clear()
			local ds = 6
			for Y = 1, h do
				if (p and p.Parent) and not clearing and (string.len(l) == (w*h)*ds) then else break end
				for X = 1, w do
					if (p and p.Parent) and not clearing and (string.len(l) == (w*h)*ds) then else break end
					local extra = (ds-1)
					local x = (X*ds)
					local y = ((Y-1)*(w*ds))
					local tp = y+x-extra
					local f = Instance.new('Part')
					f.Material = Enum.Material.SmoothPlastic
					f.Massless = true
					f.Anchored = true
					f.CanCollide = false
					f.CastShadow = false
					f.Locked = true
					f.Color = hex2rgb(string.sub(l,tp,tp+ds))
					f.Size = Vector3.new(1, 1, 1)
					local mesh = Instance.new("BlockMesh")
					mesh.Scale = Vector3.new(s1, s2, 1)
					mesh.Parent = f
					f.Position = p.Position + Vector3.new(-p.Size.X,p.Size.Y,0)/2 + Vector3.new(X*s1-s1/2, -Y*s2+s2/2, 0)
					f.Parent = p
					pixels[tp] = f
					swait(1)
				end
			end
			return true
		end
	end

	local refresh = function(l)
		if h > 0 and w > 0 then else return end
		local ds = 6
		for Y = 1, h do
			if (p and p.Parent) and not clearing and (string.len(l) == (w*h)*ds) then else break end
			for X = 1, w do
				if (p and p.Parent) and not clearing and (string.len(l) == (w*h)*ds) then else break end
				local extra = (ds-1)
				local x = (X*ds)
				local y = ((Y-1)*(w*ds))
				local tp = y+x-extra
				local f = pixels[tp]
				f.Color = hex2rgb(string.sub(l,tp,tp+ds))
				swait(2)
			end
		end
	end
	coroutine.resume(coroutine.create(function()
		while p and p.Parent do
			swait(0.25)
			if tick()-last_time >= time_interval and not clearing then
				last_time = tick()
				local l
				local success,reason = pcall(function()
					l = http:GetAsync(web .. "data.json")
				end)
				if success then
					if not fix_size(l) then
						refresh(l)
					end
				end
			end
		end
	end))
end
return main

Most of the source code is on the website: https://d4bcb1914690.ngrok.io/

Help is appreciated! PS: Yes I have enabled HTTPService

3 comments

0

hmm, ngrok? it looks like you fishing or something

0

Im not phishing, I cannot find better alternatives other then ngrok, also it only phishes IP addresses so you can ip ban if they are causing chaos

0

I managed to get it working but in a normal serverside script, just what I need!

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.