A parts material is used to make beautifull environments but, what if you could change the textures for mobile players? in this post you’re going to learn how you can do it
local UserInputService = game:GetService("UserInputService")
that’s just how you start your script easier.
next we will search our part in the Workspace.
local Part = script.Parent.Part
that’s another variable. now let’s start scripting shall we?
under this text is the whole script!
local UserInputService = game:GetService("UserInputService")
local Workspace = game:GetService("Workspace")
local Part = Workspace.Part
if UserInputService.TouchEnabled == true then
Part.Material = Enum.Material.SmoothPlastic
end
That’s what i have for now! i hope that you found this helpfull, if you did make sure to tell me i would love to know if you found this article helpfull
one last thing! this works with a or with a .
alright have fun with this tutorial! cya guys later!
Just to clarify, this will also change material for touch screen computers, even if it’s a laptop or desktop.
There are many topics on the devforum about more reliable ways to determine if it’s a mobile device, though generally this is not the intended use of UserInputService. The service is about input and not graphics or processing capability, which I assume is why you’d want to change the material for mobile.
local Workspace = game:GetService("Workspace")
local Part = Workspace.Part --// or whatever the path is
Currently the script only works if the script is a direct parent of Workspace which would cause it to break for anyone who is putting this in ServerScriptService.
Specifying the variable without relying on the script’s parent allows greater versatility!
Unfortunately this is not sufficient for the Resources category. This is just extremely simple mobile input detection, which is already offered as example code on the Developer Hub.