Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

TouchEnabled Not working?

Asked by 8 years ago

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)
1
Is it in a script or a LocalScript? TouchEnabled (and anything to do with the UserInputService) will only work on LocalScripts. GoldenPhysics 474 — 8y
0
That's weird, because I heard that Playeradded only works in server scripts. i'll try to find a way. SpazzMan502 133 — 8y

Answer this question