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.
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()’.
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)
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.