Changing a parts material on Mobile devices

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 Png or with a Png (1) .

alright have fun with this tutorial! cya guys later!

3 Likes

i have done that, thanks for the tip!

1 Like

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.

3 Likes

i’ve changed the title my friend.

I would recommend changing this line:

local Part = script.Parent.Part

to something like

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!

thanks for the tip! i’ve just used it! again thanks for the tip!

If you want it for touch screen computers then you do a statement asking if the player has TouchEnabled AND KeyboardEnabled.

This might work because I just heard about doing that somewhere.

I really cant help beacause I know nothing about developing on MOBILE .Basically im Useless

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.