local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local player = Players.LocalPlayer
local camera = workspace.CurrentCamera
local gui = Instance.new("ScreenGui")
gui.Name = "CrosshairGui"
gui.ResetOnSpawn = false
gui.IgnoreGuiInset = true
gui.Parent = player:WaitForChild("PlayerGui")
local dot = Instance.new("Frame")
dot.Name = "CenterDot"
dot.Size = UDim2.fromOffset(4, 4)
dot.Position = UDim2.fromScale(0.5, 0.5)
dot.AnchorPoint = Vector2.new(0.5, 0.5)
dot.BackgroundColor3 = Color3.new(1, 1, 1)
dot.BorderSizePixel = 0
dot.Parent = gui
local corner = Instance.new("UICorner")
corner.CornerRadius = UDim.new(1, 0)
corner.Parent = dot
local rayParams = RaycastParams.new()
rayParams.FilterType = Enum.RaycastFilterType.Exclude
local function isWhite(color)
return color.R > 0.9
and color.G > 0.9
and color.B > 0.9
end
RunService.RenderStepped:Connect(function()
camera = workspace.CurrentCamera
local character = player.Character
rayParams.FilterDescendantsInstances =
character and {character} or {}
local viewport = camera.ViewportSize
local ray =
camera:ViewportPointToRay(
viewport.X / 2,
viewport.Y / 2
)
local result =
workspace:Raycast(
ray.Origin,
ray.Direction * 1000,
rayParams
)
if result
and result.Instance:IsA("BasePart")
and isWhite(result.Instance.Color) then
dot.BackgroundColor3 =
Color3.new(0, 0, 0)
else
dot.BackgroundColor3 =
Color3.new(1, 1, 1)
end
end)