--Reset Humanoid.Sit whenever they jump
script.Parent.Touched:Connect(function(HitPart)
local Character = HitPart.Parent
local Humanoid = Character:FindFirstChild("Humanoid")
if Humanoid then
Humanoid.Sit = true
Humanoid.JumpPower = 0
local connection = nil
connection = Humanoid.Jumping:Connect(function(active)
if not active then return end
Humanoid.Jump = false
Humanoid.Sit = true
end)
end
end)
--Disconnect the connection whenever you want to stop force-sitting
This doesn’t really work since the player can spam jump and be able to get out of his sitting position.
Maybe i am bit late, but try setting the Humanoid UseJumpPower to true
Did you ever find a solution for this problem? I’ve seen other games that do it.
Player can not get out seat if they have jumpPower set to 0 and usePowerJump set to true (default by roblox), to let it go set powerjump to 50 (default too)
local seat = Instance.new("Seat")
seat.Anchored = true
seat.Position = Vector3.new(0, 1, 0)
seat.Parent = workspace
local currentPlayer = nil
local function onOccupantChanged()
local humanoid = seat.Occupant
if humanoid then
local character = humanoid.Parent
local player = Players:GetPlayerFromCharacter(character)
if player then
print(player.Name .. " has sat down")
currentPlayer = player
character.Humanoid.UseJumpPower = true --default by roblox, set it if you changed it
character.Humanoid.JumpPower = 0
return
end
end
--if currentPlayer then
-- print(currentPlayer.Name .. " has got up")
-- currentPlayer = nil
--end
end
seat:GetPropertyChangedSignal("Occupant"):Connect(onOccupantChanged) ```
1 Like
This seems to work, even while sitting.
--local script
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local UIS = game:GetService("UserInputService")
UIS.JumpRequest:Connect(function()
print("tried to jump")
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
end)
Actually have been looking for a real way to do this for awhile. Thanks for the question!
1 Like
Both solutions seem to work. Thank you!
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.