You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
Get the color of the hit part and set the Frame BackgroundColor to hit.Color - What is the issue? Include screenshots/videos if possible!
ScreenPointToRay doesn’t seem to work? No hit event occurs.
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Honestly, not sure if I know about any solutions myself. Yes I did look, haven’t found much.
I’m creating a simple script that will ‘render’ the camera view.
Encountered an issue that makes my further work impossible to complete, I have no more ideas on how to approach that problem.
local Service = {}
Service.RunService = game:GetService("RunService")
Service.Players = game:GetService("Players")
local Player = Service.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera
local Viewport = Camera.ViewportSize
repeat wait()
Camera.CameraType = Enum.CameraType.Scriptable until
Camera.CameraType == Enum.CameraType.Scriptable
Camera.CFrame = workspace.CFrame.CFrame
Character = Character:GetChildren()
wait(2)
for x = 1,100 do
wait()
for y = 1,100 do
local Frame = Instance.new("Frame",script.Parent)
Frame.BorderSizePixel = 0
Frame.BackgroundColor3 = Color3.fromRGB(0,0,0)
Frame.Size = UDim2.new(0,10,0,10)
Frame.Position = UDim2.new(0,x*10,0,y*10)
local unitRay = Camera:ScreenPointToRay(x, y)
local ray = Ray.new(unitRay.Origin, unitRay.Direction * 1000)
local hit,pos,norm = workspace:FindPartOnRayWithWhitelist(ray,Character)
if (hit) then
print(hit.Name)
Frame.BackgroundColor3 = hit.Color
else
Frame.BackgroundColor3 = Color3.fromRGB(14, 171, 255)
end
end
end
Any help will be truly appreciated.