I have a simple trip part script and when the player touches the part it makes them trip. But I need it to make the player not stand up from the sitting position for 3 seconds. I have tried multiple things and nothing worked. I tried using JumpHeight and JumpPower but doesnt work.
Here is the script:
local trippart = script.Parent
trippart.Touched:Connect(function(part)
if part.Parent:FindFirstChild("Humanoid")then
part.Parent.Humanoid.Sit = true
end
end)
You’ll probably want to set this up differently but this will stop a jump totally. Just by making it false the moment it turns true. You could redo the key and have a way to turn that off when needed but, this is pretty slick and cheap …
local humanoid = game.Players.LocalPlayer.Character:FindFirstChildOfClass("Humanoid")
humanoid:GetPropertyChangedSignal("Jump"):Connect(function()
if humanoid.Jump then humanoid.Jump = false end
end)
So after they sit for 3 seconds do you need to stand them up?
This seems a bit hacky but it works for the most part. You’ll need to give it some love.
If you stand them up while still on the trippart things go a bit wonky. So I’ve added a few lines for that.
local player = game.Players.LocalPlayer
local trippart = workspace:WaitForChild("Part")
local function disableJump(humanoid)
local conn
conn = humanoid:GetPropertyChangedSignal("Jump"):Connect(function()
if humanoid.Jump then humanoid.Jump = false end
end) task.wait(3)
if conn then conn:Disconnect() end
trippart.CanTouch=false
humanoid.Sit = false
task.wait(2)
trippart.CanTouch=true
end
trippart.Touched:Connect(function(part)
local humanoid = part.Parent:FindFirstChildOfClass("Humanoid")
if humanoid and part.Parent == player.Character then
humanoid.Sit = true
disableJump(humanoid)
end
end)
Sorry I am working on 3 here … yours does have a script. My bad.
This is all done in a local script. The stopping the jump works. You’ll have to figure out the rest.
There is enough here to start working on this. This is definitely going to take some testing.
Maybe your touch part could be a seat. Then remove the weld to stand them up.
You can disable jumping by disabling the jump humanoid state with Humanoid:SetStateEnabled:
local trippart = script.Parent
trippart.Touched:Connect(function(part)
local humanoid = part.Parent:FindFirstChild("Humanoid")
-- If there is a humanoid and it can jump
if humanoid and humanoid:GetStateEnabled(Enum.HumanoidStateType.Jumping) then
-- Make the humanoid sit and disable jumping
part.Parent.Humanoid.Sit = true
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
-- Wait 3 seconds and re-enabled jumping
task.wait(3)
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
end
end)
You can do some other cool stuff with SetStateEnabled like disabling walking/running, disabling climbing, etc.
local trippart = script.Parent
trippart.Touched:Connect(function(part)
local humanoid = part.Parent:FindFirstChild("Humanoid")
-- If there is a humanoid and it can jump
if humanoid and humanoid:GetStateEnabled(Enum.HumanoidStateType.Jumping) then
-- Make the humanoid sit and disable jumping
part.Parent.Humanoid.Sit = true
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false)
-- Wait 3 seconds and re-enabled jumping
task.wait(3)
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, true)
end
end)
This works inside a Script with its RunContext set to Client put inside a part:
local trippart = script.Parent
trippart.Touched:Connect(function(part)
local humanoid = part.Parent:FindFirstChild("Humanoid")
-- If there is a humanoid and it can jump
if humanoid and humanoid:GetStateEnabled(Enum.HumanoidStateType.Jumping) then
-- Make the humanoid sit and disable jumping
part.Parent.Humanoid.Sit = true
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
humanoid:SetStateEnabled(Enum.HumanoidStateType.Running, false)
-- Wait 3 seconds and re-enabled jumping
task.wait(3)
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
humanoid:SetStateEnabled(Enum.HumanoidStateType.Running, true)
end
end)
(It turns out the one that needs to be disabled is “Running”.)
This doesn’t stop the character from being able to exit the Seated state.
I tried it just now while debugging the code above on both the client and the server and it didn’t work. Perhaps there is a way for it to work though.