Welcome to the Forums!
Join thousands of other Roblox members with a free account.
Create Forum Account

How to do force sit

  • This website was created by Roblox members to replace the official forums (because Roblox shut them down) Join us if you like Roblox!

cacalol

Member
Reputation: 0 / 0 / 0
Sep 2, 2021
50
1
3
8
Roblox
easyreooo
Im making a game where a player sits on a Seat and they cant escape by jumping or anything else or do i do that
 

CallMeKY

Moderator
Ultra
Reputation: 8 / 0 / 0
Feb 25, 2018
1,787
98
882
113
Maine, USA
Roblox
CallMeKY
Discord
CallMeKY#5012
Im making a game where a player sits on a Seat and they cant escape by jumping or anything else or do i do that
I think the simplest option is to disable their jump state. For this example the server script is in the seat and the local script is in StarterCharacterScripts.

server script:
local players = game:GetService('Players')
local seat = script.Parent

local toggleJumpEvent = Instance.new('RemoteEvent', game:GetService('ReplicatedStorage'))
toggleJumpEvent.Name = 'ToggleJump'

seat:GetPropertyChangedSignal('Occupant'):Connect(function()
    if not seat.Occupant then return end
    toggleJumpEvent:FireClient(players:GetPlayerFromCharacter(seat.Occupant.Parent), false)
    
    -- example of how to reenable jump
    wait(5)
    toggleJumpEvent:FireClient(players:GetPlayerFromCharacter(seat.Occupant.Parent), true)
end)

local script:
local human = script.Parent:WaitForChild('Humanoid', 300)

game:GetService('ReplicatedStorage'):WaitForChild('ToggleJump', 300).OnClientEvent:Connect(function(canJump)
    human:SetStateEnabled(Enum.HumanoidStateType.Jumping, canJump)
end)