I’m trying to make a seat that only people that are playing on a computer can sit on and mobile users cant. (Basically what I’m saying is if a user that is playing on a computer they can stay on the seat with no problem but if a user is on a mobile device they automatically get out. but since I’m not good at scripting at all I don’t know how to do this)
What the issue is:
In my game I added Pianos and Mobile Users can’t use them properly because if they do they either get stuck because the exit button is out of their screen or they spam the notes which makes the other pianos break entierly until they stop spamming the notes (If someone spams a lot of notes on the piano the other pianos cant play a note because the audio is getting spammed basically forcefully stopping the other pianos audio (I have tried fixing this but nothing worked because I found NOTHING!)
What Solutions I have tried:
I have tried using this code (its a local script in the seat)
local UserInputService = game:GetService("UserInputService")
if UserInputService.TouchEnabled and not UserInputService.KeyboardEnabled and not UserInputService.MouseEnabled then
return
elseif not UserInputService.TouchEnabled and UserInputService.KeyboardEnabled and UserInputService.MouseEnabled then
--Code goes here
end
But dont know what to put in the “–Code here” I have tried searching everywhere and tryed using a code that if you touch a part you jump or something like that but I don’t how scripting works so everything has failed and I really need help. What I’ve been thinking is “if someone that isn’t a PC User for example Player1 is a mobile user and Player2 is a PC user that Player2 is allowed to freely use the piano but Player1 can’t use the piano because they are one a Mobile Device” But again don’t know how to do this at all because it’s just very confusing…
Could someone possibly help?
I have tried listing every detail I can sorry if I missed some…
local char = game.Player.LocalPlayer.Character
local hum = char:WaitForChild("Humanoid")
local chosenseat = NameOfSeat -- Replace with your seat Example Workspace.Seat
chosenseat:Sit(hum)
local UserInputService = game:GetService("UserInputService")
if UserInputService.TouchEnabled and not UserInputService.KeyboardEnabled and not UserInputService.MouseEnabled then
return
elseif not UserInputService.TouchEnabled and UserInputService.KeyboardEnabled and UserInputService.MouseEnabled then
local char = game.Player.LocalPlayer.Character
local hum = char:WaitForChild("Humanoid")
local chosenseat = workspace.Piano.one.Bench.Seat -- Replace with your seat Example Workspace.Seat
chosenseat:Sit(hum)
end
How do I make it prevent the user from entering the seat if they are mobile? Because I don’t know how because I’m not good at scripting at all.
The code:
(local script)
local UserInputService = game:GetService("UserInputService")
if UserInputService.TouchEnabled and not UserInputService.KeyboardEnabled and not UserInputService.MouseEnabled then
return
elseif not UserInputService.TouchEnabled and UserInputService.KeyboardEnabled and UserInputService.MouseEnabled then
local char = game.Player.LocalPlayer.Character
local hum = char:WaitForChild("Humanoid")
local chosenseat = workspace.Piano.one.Bench.Seat -- Replace with your seat Example Workspace.Seat
chosenseat:Sit(hum)
end
local UserInputService = game:GetService("UserInputService")
local Player = game:GetService("Players").LocalPlayer
local chosenseat = workspace.Piano.one.Bench.Seat
chosenseat.ChildAdded:Connect(function(Child)
if Child:IsA("Weld") and Child.Name == "SeatWeld" then
if UserInputService.TouchEnabled and not UserInputService.KeyboardEnabled and not UserInputService.MouseEnabled then
local char = Player.Character
local hum = char:WaitForChild("Humanoid")
task.wait(0.1)
hum.Sit = false
end
end
end)
I do not know much about scripting but you need to put the “PCOnlyScript” into the starterplayerscripts then you make a script that only lets pc players sit on it where the seat function is then see if that works.