I tried the script in an empty baseplate and it acted the same way
I left the print statement in there on accident (that was me checking which state I needed to disable).
Here is a place file with it set up:
TripPartDevForumExample.rbxl (55.1 KB)
When the player touches the purple part they fall over in a seated position and can’t get up by jumping for 3 seconds, after which they can get up by jumping.
oops, the entire solution was that it was suppose to be a local script. I tried a local script before and it just wouldnt work, but somehow it works now👍🏼
I think there might be a bug, here is an updated version:
local trippart = script.Parent
local states = {
Enum.HumanoidStateType.Running,
Enum.HumanoidStateType.Jumping,
Enum.HumanoidStateType.Freefall,
Enum.HumanoidStateType.Landed,
Enum.HumanoidStateType.Climbing,
Enum.HumanoidStateType.Swimming,
Enum.HumanoidStateType.GettingUp,
Enum.HumanoidStateType.FallingDown
}
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.Running) then
-- Make the humanoid sit and disable other states
part.Parent.Humanoid.Sit = true
for _, state in ipairs(states) do
humanoid:SetStateEnabled(state, false)
end
-- Wait 3 seconds and re-enabled other states
task.wait(3)
for _, state in ipairs(states) do
humanoid:SetStateEnabled(state, true)
end
end
end)
The bug is because when the player is falling they can transition from Seated to Freefall which isn’t blocked by disabling Running. The same problem probably happens for the Swimming state if they trip into water. So the updated code just disable those states also.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.