Stop a player from getting up

  1. What do you want to achieve?
    I want to make it so a player cannot get up after being sat down.

  2. What is the issue?

  3. What solutions have you tried so far?
    I looked at a few posts on the devforum.

Basically I’m making a game called Sardines, if you don’t know what the game Sardines is, it’s a game where someone hides, then other people need to find the hider. When someone finds the hider, they join them in hiding.

And I want to be able to make it so you sit down and wont be able to get back up because you’re hiding.

local Notif = require(script.Parent.Notifier)


game.ReplicatedStorage.Hide.OnServerEvent:Connect(function(hider)
	print(hider.UserId)
	if hider.UserId == game.ReplicatedStorage.HiderId.Value then
		-- If the user is the real hider
		hider.Character.Humanoid.JumpPower = 0
		hider.Character.Humanoid.WalkSpeed = 0
		hider.Character.Humanoid.Sit = true
		
		for i,v in pairs(hider.Character:GetChildren()) do
			if v:IsA("BasePart") then
				
			else
				warn(v.Name.." is not a basepart.")
			end
		end
	else
		-- Uhoh
		hider:Kick("You've been detected for exploiting.")
	end
end)

Everything in the script above works, however the player can still use the space bar to get back up.

If you don’t want the player to be able to get back up, you might consider using PlatformStand instead of Sit. That will essentially do the same thing. If you still want the animation for sitting, you could play that animation on top (or maybe some sort of hiding animation instead!)

There are multiple soloutions for this.
@Barothoth was right, but if you would like to keep the classic sit in your game, then you could make the player’s JumpPower 0 once you want them to remain sitting. When is the JumpPower 0, the player won’t be able to get up.

You just made me realise I put the completely wrong script on my post.

I’ll update it in a second.

Like @MegaBorecYT said, changing the JumPower to 0 would be the optimal solution. Also, your script doesn’t make sense.

I was gunna suggest this because I totally thought that was the case but I guess not anymore…?
https://gyazo.com/3fad1966ff8b59d0582e02a4f4eee877

2 Likes

Oh, it doesn’t work anymore? I never knew that lol.

2 Likes

Right?? That definitely used to work. Maybe it only applies to getting out of seats.

Yeah, I’ll try and write a few lines of code to see if I can come up with something.

2 Likes

Oh wow! You are right! This thing used to work. Thank you for updating us!

2 Likes

I did this by forcing “Sit” to be true and “Jump” to be false.

game.Players.PlayerAdded:Connect(function(p)
	p.CharacterAdded:Connect(function(c)
		if c.Humanoid.Sit == true then
			while wait(.0001) do
				c.Humanoid.Jump = false
				c.Humanoid.Sit = true
			end
		end
	end)
end)

And this is where I placed the script:
image

There might be a more efficient way of doing this, but this method is functional.

1 Like

Hello!
This function would work, however you are using while wait(.0001) do, which is not really a best thing what you can do.
More about this topic can be found over here: Avoiding wait() and why

2 Likes

Yeah, I said that it was not the most efficient thing. I rushed the script but just wanted to get a valid answer to him asap.

2 Likes

Okay so I can up with a pretty simple “but it works” solution.

Basically I just made the player sit then anchor them. :man_shrugging:

Found a good workaround! Do this as soon as you make them sit and they won’t be able to get back up :slight_smile:

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

3 Likes