Changing humanoid state not working

Hello devforum community, recently I had some trouble with some handcuffs. The problem made the cop be stuck on the ground when holding someone (When the cop holded someone the arrested person’s humanoid root part was welded tot he tool handle). In one of the replies, it was suggested to force the humanoid state to be running istead of running no physics to fix the issue. I did some testing and it worked when I make the state of the cop running and the state of the crim running no physics. Now, Im having problems changing the humanoid state.

When I arrest the other player in the multiple player test in roblox studio, sometimes it works and the states are like I said before, running for the cop, and running no physics for the crim. But sometimes, for some reason it is running for the 2 of them, and that makes the cop not be able to walk.

This is the script im using to change the state:

runs.Stepped:Connect(function()
	print("Loop")
	if thischar ~= nil then
		if holding == true then
			print("Loop accepted")
			thischar.Humanoid:ChangeState(Enum.HumanoidStateType.Running)
			print(tostring(thischar.Humanoid:GetState()).. "  Cop character")
			otherchar.Humanoid:ChangeState(Enum.HumanoidStateType.RunningNoPhysics)
			print(tostring(otherchar.Humanoid:GetState()).. "  Crim character")
		end
	end
end)


1 Like

Try this and if it does not work contact me on discord. Sxmply.0001

script.Parent.Equipped:connect(function(m)
m.Button1Down:connect(function()
if m.Target~=nil then
print(m.Target:GetFullName())
p=nil
_,p=pcall(function() return game.Players[m.Target.Parent.Name] end)
print(p)
print(m.Target.Parent.Name)
if p~=nil then
local detained=p
coroutine.wrap(function()
        local c=p
        while p==c do wait() pcall(function()
                p.Character.Torso.Anchored,p.Character.Torso.CFrame=true,game.Players.LocalPlayer.Character.Torso.CFrame*CFrame.new(0,0,-2.5)
        end) end
        print('END OF DETAIN LOOP')
        pcall(function() c.Character.Torso.Anchored=false end)
end)()
else print('no p') end
end
end)
end)