I think I found a way that seems to work for me.
First, put in Normal Script in the seat you want, then put in the following code:
script.Parent.Changed:Connect(function()
if script.Parent.Occupant then
local player = game:GetService("Players"):GetPlayerFromCharacter(script.Parent.Occupant.Parent)
if player then
game:GetService("ReplicatedStorage").PlayerOnMobile:FireClient(player)
end
end
end)
game:GetService("ReplicatedStorage").PlayerOnMobile.OnServerEvent:Connect(function(player, IsMobile)
if IsMobilbe == false then
print(player.Name.." Is on PC")
-- Code here
elseif IsMobile == true or IsMobile == nil then
print(player.Name.." Is on Mobile")
local humanoid = player.Character:FindFirstChildWhichIsA("Humanoid")
if humanoid then
humanoid.Jump = true
end
end
end)
Next, Create a RemoteEvent in ReplicatedStorage called PlayerOnMobile (Or any other name, but the script has to be changed to reflect the new name).
Then, create a LocalScript, call it any name you want, and place it in StarterPlayer > StarterPlayerScripts. Put this code in the LocalScript:
local replicatedstorage = game:GetService("ReplicatedStorage")
local userinput = game:GetService("UserInputService")
replicatedstorage.PlayerOnMobile.OnClientEvent:Connect(function()
if userinput.TouchEnabled == true and userinput.KeyboardEnabled == false and userinput.MouseEnabled == false then
replicatedstorage.PlayerOnMobile:FireServer(true)
elseif userinput.TouchEnabled == false and userinput.KeyboardEnabled == true and userinput.MouseEnabled == true then
replicatedstorage.PlayerOnMobile:FireServer(false)
end
end)
Here’s a summary of how it works: When a player sits on the seat, It gets the player from the character that is sitting on that seat using Players:GetPlayerFromCharacter()
It then fires the RemoteEvent named PlayerOnMobile in ReplicatedStorage, which goes to the local script in the player’s PlayerScripts. Over there, it checks if they are on mobile or not, by checking its KeyboardEnabled, MouseEnabled, and TouchEnabled values on UserInputService, and then fires the RemoteEvent with either a true if they are on mobile, or false if they are on PC.
Back on the Script, it checks if the IsMobile value is false or true. If it is false, you can run code such as to open a Gui. But if it’s true, then it changes the Jump value in the player’s humanoid to true, which removes them from the seat.
I tried it myself and it worked, so I hope it works for you