
Credits: bacondevthethird
why did i even make this thing
local Players = game:GetService("Players")
local AssetService = game:GetService("AssetService")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local Workspace = game:GetService("Workspace")
local W, H = 160, 120
local MAX_DIST = 1000
local camera = Workspace.CurrentCamera
local playerGui = Players.LocalPlayer:WaitForChild("PlayerGui")
local existing = playerGui:FindFirstChild("RaytracerGui")
if existing then existing:Destroy() end
local sg = Instance.new("ScreenGui")
sg.Name = "RaytracerGui"
sg.ResetOnSpawn = false
sg.IgnoreGuiInset = true
sg.Parent = playerGui
local img = Instance.new("ImageLabel")
img.Size = UDim2.fromScale(1, 1)
img.ScaleType = Enum.ScaleType.Stretch
img.BackgroundColor3 = Color3.new(0, 0, 0)
img.Parent = sg
local editable = AssetService:CreateEditableImage({ Size = Vector2.new(W, H) })
img.ImageContent = Content.fromObject(editable)
local pixbuf = buffer.create(W * H * 4)
local rayParams = RaycastParams.new()
rayParams.FilterType = Enum.RaycastFilterType.Exclude
local function refreshFilter()
local char = Players.LocalPlayer.Character
rayParams.FilterDescendantsInstances = char and { char } or {}
end
refreshFilter()
Players.LocalPlayer.CharacterAdded:Connect(refreshFilter)
local function vlerp(a, b, f)
return a + (b - a) * f
end
local WHITE = Vector3.new(1, 1, 1)
local SKY = Vector3.new(0.5, 0.7, 1.0)
local lightDir = Vector3.new(-0.4, 1, 0.3).Unit
local function skyColor(rd)
local t = 0.5 * (rd.Y + 1)
return vlerp(WHITE, SKY, t)
end
local connections = {}
local function shutdown()
for _, conn in connections do
if conn.Connected then conn:Disconnect() end
end
table.clear(connections)
if sg then sg:Destroy() end
print("raytracer killed")
end
local function render()
local cf = camera.CFrame
local origin = cf.Position
local fovRad = math.rad(camera.FieldOfView)
local halfH = math.tan(fovRad * 0.5)
local halfW = halfH * (W / H)
local right = cf.RightVector
local up = cf.UpVector
local forward = cf.LookVector
local offset = 0
for y = 0, H - 1 do
local ndcY = (1 - (y + 0.5) / H * 2) * halfH
for x = 0, W - 1 do
local ndcX = ((x + 0.5) / W * 2 - 1) * halfW
local dir = (forward + right * ndcX + up * ndcY).Unit
local result = Workspace:Raycast(origin, dir * MAX_DIST, rayParams)
local r, g, b
if result then
local base = result.Instance.Color -- Color3
local n = result.Normal
local diff = math.max(n:Dot(lightDir), 0)
local shade = 0.25 + diff * 0.75 -- ambient + lambert
r = base.R * shade
g = base.G * shade
b = base.B * shade
else
local c = skyColor(dir)
r, g, b = c.X, c.Y, c.Z
end
buffer.writeu8(pixbuf, offset, math.clamp(r, 0, 1) * 255)
buffer.writeu8(pixbuf, offset + 1, math.clamp(g, 0, 1) * 255)
buffer.writeu8(pixbuf, offset + 2, math.clamp(b, 0, 1) * 255)
buffer.writeu8(pixbuf, offset + 3, 255)
offset += 4
end
end
editable:WritePixelsBuffer(Vector2.zero, Vector2.new(W, H), pixbuf)
end
table.insert(connections, UserInputService.InputBegan:Connect(function(input, gpe)
if gpe then return end
if input.KeyCode == Enum.KeyCode.X then
shutdown()
end
end))
table.insert(connections, RunService.Heartbeat:Connect(render))
print("live raytracer running - press X to kill")Comments section coming soon...
To use this script, you need a Roblox Executor. Simply copy the script from this page, paste it into your executor, and run it while you are in the Universal game.
This script may require a payment or subscription. Please check the script's description for more details.
Yes, this script has a key system. You may need to complete a task or join a Discord server to get a key.
Yes, this script is designed to be compatible with mobile executors.




