Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would i detect if humanoid state has been interrupted?

Asked by 5 years ago

I don't know how you would detect if state has been interrupted and after a second it would say if it got interrupted.

The script looks like this: local animation = script.Parent.Freefall

local humanoid = script.Parent.Parent.Parent.Humanoid

local character = humanoid.Parent

humanoid.FreeFalling:Connect(function()

wait(1)

if character:FindFirstChild("Rope") == nil then

humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, true)

humanoid:ChangeState(Enum.HumanoidStateType.Ragdoll)

local ActiveTracks = humanoid:GetPlayingAnimationTracks()

for _,v in pairs(ActiveTracks) do

v:Stop()

end

local load = humanoid:LoadAnimation(animation)

character.Animate.Disabled = true

load:Play()

humanoid.GettingUp:Connect(function()

load:Stop()

character.Animate.Disabled = false

end)

end

end)

1 answer

Log in to vote
0
Answered by
Ankur_007 290 Moderation Voter
5 years ago

If by "interrupted" you mean changed, then you can use the Humanoid.StateChanged event.

Here's an example of the same: lua game.Players.PlayerAdded:Connect(function(plr) plr.CharacterAdded:Connect(function(char) char:FindFirstChild("Humanoid").StateChanged:Connect(function(old, new) -- old state and new state print("Humanoid went from "..tostring(old).." to "..tostring(new).."!") -- You can also check the old and new states to make things occur at certain points like falling down end) end) end)


Useful links and articles:


On a sidenote, please remember to use codeblocks when posting scripts as such:

Input

```lua print("Hello World!") ```

Output

lua print("Hello World!")


Please comment if you have any questions or I have made any mistakes

Ad

Answer this question