How To Keep Player Sitting

How do I keep the player in the sitting position? I am trying to make the player sit down, and not allow him to get back up. How would I do that? This will be used for a slide.
This is my current code

    script.Parent.Touched:Connect(function(HitPart)
	local Character = HitPart.Parent
	local Humanoid = Character:FindFirstChild("Humanoid")
	
	if Humanoid then
		Humanoid.Sit = true
		Humanoid.JumpPower = 0
	
	end
end)

The problem with this code is that when the player touches the part, it will sit the player down, but the player can get back up.

Thanks :smiley:

2 Likes

Are you sure? I tested it for myself. I inserted the script into a seat and it worked perfectly, I wasn’t able to get up.

1 Like

just anchor HumanoidRootPart blah blah

i did not add a seat, just a part that if touched, will make the player sit down.

I have tried that but it doesn’t work

Here is a video, as you can see the player can get back up from the sitting position.

Ahh, try this:

script.Parent.Touched:Connect(function(HitPart)

local Character = HitPart.Parent
local Humanoid = Character:FindFirstChild("Humanoid")
local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")

if Humanoid then
	Humanoid.Sit = true
	if Humanoid.Sit == true then
		Humanoid.JumpPower = 0
		HumanoidRootPart.Anchored = true

end end end)

However, that stops them from moving completely, I will advise adding ‘wait()’.

1 Like

Set the HumanoidStateType to Physics after they touch the part

script.Parent.Touched:Connect(function(HitPart)
	local Character = HitPart.Parent
	local Humanoid = Character:FindFirstChild("Humanoid")
	
	if Humanoid then
		Humanoid.Sit = true
		Humanoid.JumpPower = 0
        Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
	end
end)
2 Likes

Yes, that works great! It doesn’t matter if they can’t move because they are sliding down. :smiley:

Glad I was able to help! I advise adding wait() for the slide ending so they’re able to get back up.

1 Like

where should I add the wait()?

script.Parent.Touched:Connect(function(HitPart)
local Character = HitPart.Parent
local Humanoid = Character:FindFirstChild("Humanoid")
local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")

if Humanoid then
	wait(0.5)
	Humanoid.Sit = true
	if Humanoid.Sit == true then
		Humanoid.JumpPower = 0
		HumanoidRootPart.Anchored = true
		wait(10) -- Change 10 to when the slide ends
		if Humanoid then
			Humanoid.Sit = false
			if Humanoid.Sit == false then
				Humanoid.JumpPower = 50
				HumanoidRootPart.Anchored = false
			end

		end
	end
end end)

Wait(10) by that I mean like keep trying 5,10,15 and so on until the slide ends to find the perfect time for the player to be able to get back up again.

I think I noticed a problem, I thought that it would restrict the player’s movements but still allow him to slide down the slide, but it doesn’t. He stays stuck and unable to move.

Ah, give me a moment to find a solution.

1 Like

Sorry for a late response, looking for various solutions.

1 Like

All good! Thanks for trying :smiley: I am also trying different ways

Yeah, great idea, but Physics StateType can only be set on the client.

2 Likes

then I would need to use a remote event from Server to Client?

Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)