I'm trying to make mobile support in the form of a gui, but this script doesn't work.

local Players = game:GetService("Players")
 
function onPlayerAdded(player)
     if game:GetService('UserInputService').TouchEnabled then
	script.Parent.Frame.Visible = true
else
	script.Parent.Frame.Visible = false
end
end

Players.PlayerAdded:connect(onPlayerAdded)

Thanks for any help!

3 comments

0

UserInputService is localscript only.

0

Its already a local script

0

PlayerAdded won't work for the player running the LocalScript. It will instead wait for a new player. Use LocalPlayer instead.