As a Roblox developer, it is currently too hard to make proposed solutions to having Samsung Galaxy S Pen phone devices coded into my script for a sketching board I made–which would be very beneficial, and currently, I feel like there is not a compromise to make in my scripts to support and pinpoint exactly the use of a stylus on mobile, as trying to support or code a possible solution for this would only end up being more difficult as ‘fingers’ would likely end up being detected. I recognized that there
I have a Samsung Galaxy S25 Ultra.
proof of concept, or something of those sorts (Correct me if any of this is wrong)
-- LocalScript in StarterPlayerScripts
local userInputService = game:GetService("UserInputService")
local function onInputBegan(inputObject, gameProcessedEvent)
if gameProcessedEvent then return end -- Ignore if Roblox processed the input already
if inputObject.UserInputType == Enum.UserInputType.Pen then
print("Stylus began input at:", inputObject.Position)
-- Perform a raycast from the stylus's 3D position
local camera = workspace.CurrentCamera
local rayOrigin = inputObject.Position
local rayDirection = (camera.CFrame.UpVector) -- Placeholder for actual ray direction from input
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
raycastParams.FilterDescendantsInstances = {workspace.CurrentCamera} -- Exclude camera
local raycastResult = workspace:Raycast(rayOrigin, rayDirection * 1000, raycastParams) -- Multiply by a large number for ray length
if raycastResult then
local hitPart = raycastResult.Instance
print("Stylus hit:", hitPart.Name)
-- You can now add logic based on the hitPart
end
end
end
local function onInputEnded(inputObject, gameProcessedEvent)
if gameProcessedEvent then return end
if inputObject.UserInputType == Enum.UserInputType.Pen --[[Right here ]] then
print("Stylus ended input")
-- Add logic for stylus ending interaction
end
end
userInputService.InputBegan:Connect(onInputBegan)
userInputService.InputEnded:Connect(onInputEnded)
If Roblox is able to address this issue, it would improve my development experience because it would be a great impact for mobile players and may benefit to other developers for mobile players that have a samsung S pen–or some other sort of stylus device attachment as part of their mobile device. I believe that it would benefit other phone devices that have stylus attachments. As this does not necessarily have to be samsung alone.