I was wondering if you could make something like “pick screen color” on Roblox. Does anyone have any idea if this is possible?
Do you mean like the color of a single pixel on your screen?
script.Parent.Color = Color3.new(1,0,0) or Color3.fromRGB(255,0,0)-- Color is red (Part)
Or:
script.Parent.BackgroundColor3 = Color3.new(1,0,0) or Color3.fromRGB(255,0,0) -- Color is red (GUI)
Yes, sorry I made that unclear.
There’s no way to get the screen’s pixel data, I believe. Would honestly be cool if they added it.
That’s completely different to what they’re asking…
You edit does not work either. They are looking for a method to get pixel color of a user’s screen, not setting the color of the UI or setting a part’s color.
A color picker if you will.
I believe There is most likely no non-hacky way to get the screen’s pixels directly, however the closest thing you can get to it is convert vector2 of the pixel to world data using ScreenPointToRay and the closest part to it and get its color, however this doesn’t account for UIs, textures and meshes.
Here’s an idea I have in my head.
Get the Vector2 value of a pixel that you want, raycast towards it with ScreenPointToRay(), then get the color of the part that it’s touching.
Not to mention, this won’t also certainly account for screen-space effects (bloom, blur, etc), shadows, lights, skybox, and to some extent the curvature of meshes (I believe it’s possible to use rays?)
This may certainly be the only way to get “pixel” data. Approximating to account for many effects is probably ray-tracing, which is going overboard lol.
I guess that is the closest way to achieve this. I hope Roblox will add a feature to get the color of UIs and decals in the future. Thanks to everyone else who have helped me with this topic!
Look at the video (Sorry for mentions).
The script:
script.Parent.Color = Color3.new(1,0,0) or Color3.fromRGB(255,0,0)
The topic says “get the color of a single pixel on your screen”, not “set color of a part.”
I’m not going to reply here anymore as this topic already have a solution.
Mouse.Hit returns the part the mouse is hovering over, so you can skip the process of raycasting and just get the active part like this.
Yes that’s true (if he wants the mouse’s position). Otherwise, he can use raycasting.
local Game = game
local UserInputService = Game:GetService("UserInputService")
local Players = Game:GetService("Players")
local Player = Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
local function OnInputBegan(InputObject, GameProcessed)
if GameProcessed then return end
if InputObject.UserInputType.Name ~= "MouseMovement" then return end
local GuiObjects = PlayerGui:GetGuiObjectsAtPosition(InputObject.Position.X, InputObject.Position.Y - 36) --Account for gui inset.
for _, GuiObject in ipairs(GuiObjects) do
print(GuiObject.BackgroundColor3)
end
end
UserInputService.InputBegan:Connect(OnInputBegan)
This obviously won’t work for gui objects which cast an image like ‘ImageLabels’ or ‘ImageButtons’.