I have been trying to create a makeshift filter that makes the game appear pixelated, using GUI and ray casting, with the idea being that multiple rays are sent out in a sort of “FOV cone” formation, and then returns the color of the objects the rays hit, then setting the colors of the frames in the GUI to said object colors.
However, the rays clearly seem to be going places that they are not intended to, leading to a buggy visual that does not reflect the workspace whatsoever. I am inclined to believe I have an issue with the aim of my rays, however I have spent around an hour trying to think about which way they are meant to go, and trying to modify the variables accordingly.
Here is footage of what happens:
Black tiles mean that the ray returned nil.
Code:
local run = game["Run Service"]
local SCREENSIZE = 30
local SCREEN = script.Parent.Screen
local char = game.Players.LocalPlayer.Character
char:WaitForChild("Head").CanQuery = false
local camera = workspace.CurrentCamera
run.Heartbeat:Connect(function()
for i, v in pairs(SCREEN:GetChildren()) do
if v:IsA("Frame") then
v:Destroy()
end
end
for y = 0, SCREENSIZE do
for x = 0, SCREENSIZE do
local newframe = Instance.new("Frame")
newframe.BackgroundTransparency = 0.5
newframe.Parent = SCREEN
newframe.Size = UDim2.new(1 / SCREENSIZE,0,1 / SCREENSIZE,0)
newframe.Position = UDim2.new(0 + (x / SCREENSIZE),0,0 + (y / SCREENSIZE),0)
local rayres = workspace:Raycast(camera.CFrame.Position,camera.CFrame.LookVector + Vector3.new(35 * ((y - y * 2) + (SCREENSIZE / 2)),35 * ((x - x * 2) + (SCREENSIZE / 2)),0))
if rayres == nil then
newframe.BackgroundColor3 = Color3.new(0,0,0)
elseif rayres.Instance:IsA("Part") then
newframe.BackgroundColor3 = rayres.Instance.Color
end
end
end
end)
Help would be much appreciated!