Skip to content

Instantly share code, notes, and snippets.

@ecurtiss
Created January 16, 2021 04:19
Show Gist options
  • Save ecurtiss/4653d85d8d81f9db8f21cdca2196654e to your computer and use it in GitHub Desktop.
Save ecurtiss/4653d85d8d81f9db8f21cdca2196654e to your computer and use it in GitHub Desktop.
Detects if the client is running on macOS
-- Don't use this for anything critical; Roblox could change this functionality at any time.
-- Returns true if the client is running on macOS, otherwise false.
-- Note that it yields for a heartbeat.
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local Player = Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
local COMMAND_IMAGE = "rbxasset://textures/ui/Controls/command.png"
return function()
local part = Instance.new("Part")
part.Anchored = true
part.CanCollide = false
part.CFrame = workspace.CurrentCamera.Focus
part.Transparency = 1
local proximityPrompt = Instance.new("ProximityPrompt")
proximityPrompt.Exclusivity = Enum.ProximityPromptExclusivity.AlwaysShow
proximityPrompt.KeyboardKeyCode = Enum.KeyCode.LeftControl
proximityPrompt.MaxActivationDistance = 1e6
proximityPrompt.RequiresLineOfSight = false
proximityPrompt.UIOffset = Vector2.new(0, 1e6)
proximityPrompt.Parent = part
part.Parent = workspace.CurrentCamera
RunService.Heartbeat:Wait()
local result = false
local proximityPrompts = PlayerGui:FindFirstChild("ProximityPrompts")
if proximityPrompts then
for _, prompt in ipairs(proximityPrompts:GetChildren()) do
for _, child in ipairs(prompt:GetDescendants()) do
if child:IsA("ImageLabel") and child.Image == COMMAND_IMAGE then
result = true
break
end
end
end
end
part:Destroy()
return result
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment