I’m attempting to get the RGB value of the part the player is looking at in the middle of their screen.
I’m not even sure where to start so that’s why I’ve come here. Thanks!
No, this wouldn’t be possible as Roblox doesn’t allow you access to the OS, graphics drivers, etc.
Also there should be no use case of this…
Ah okay, thank you for the response. Would it be possible to detect the color of the part the player is looking at?
simple, either raycasting from the middle of the screen straight forward or just using player:GetMouse().Target.Color
read more about mouse here
Close! But, this errors when I look at the sky. I’m not too educated on scripting as I’m a builder. Mind telling me how to fix this code? (Temporary messy code to print the value)
local mouse = game:GetService("Players").LocalPlayer:GetMouse()
while task.wait(0.2) do
print(mouse.Target.Color)
end
This is the error when I look at the sky:
Workspace.Cbrrah.LocalScript:4: attempt to index nil with 'Color'
Looking back at this, I could just put an invisible part in the sky that is blue. However, if you have any suggestions please let me know. I know I can prevent it from erroring with a PCall, but I’m not sure how to use those.
if the player isn’t hovering over anything then the mouse target will be nil so you can do a check for that
if mouse.Target ~= nil then -- "~=" means "does not equal to"
print(mouse.Target.Color)
end
Thank you kind sir, very helpful!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.