I have this script in workspace that is supposed to do stuff if the player is using a TouchEnabled Device. As an example, it's supposed to change the BrickColor of a part to green if they are on one.
For some reason, the Part turns Red, even if I play the game on my phone. There are no errors in output.
What could the problem be?
This is the script:
local Mob = game.ServerStorage:WaitForChild("Mobile")
local MobP = game.Workspace:WaitForChild("MobPart")
game.Players.PlayerAdded:connect(function(player)
wait(4)
print("Player Joined")
if game:GetService("UserInputService").TouchEnabled == true then
print("Player is on a touch device")
MobP.BrickColor = BrickColor.Green()
else
print("not on touch device")
MobP.BrickColor = BrickColor.Red()
end
end)

2 comments
Is it in a script or a LocalScript? TouchEnabled (and anything to do with the UserInputService) will only work on LocalScripts.
That's weird, because I heard that Playeradded only works in server scripts. i'll try to find a way.