Hello!
So currently I’m working on a game exactly like those stickman episodes on youtube, but I encountered a problem though. Most of the times I would find a solution through forums or find a way to fix it, but I couldn’t find any.
Basically, I want the player to stop after it has hit the wall like in TSB. But it would just dismember the player apart. I tried deleting the velocity but it doesn’t work as I noticed it was already being deleted by the debris service. I also tried researching, but I couldn’t find any relating to it.
Video:
Code:
local function ragdoll(character,opponent_character)
--sets up the player so it can be fully ragdolled--
for _,character_instances in opponent_character do
if character_instances:IsA('BasePart') then
character_instances.Anchored=false
character_instances.Massless=true
--[[character_instances.CollisionGroup='player_collidability'
physics_service:CollisionGroupSetCollidable('player_collidability','Default',true)--]]
end
if character_instances.Name=="Humanoid" then
character_instances.PlatformStand=true
character_instances:ChangeState(Enum.HumanoidStateType.Ragdoll)
end
end
--welds the opponent to the player--
for _,character_instances in opponent_character do
if character_instances:IsA('BasePart') and character_instances.Name=='HumanoidRootPart' then
local weld=Instance.new('Weld',character)
weld.Part0=character:FindFirstChild('HumanoidRootPart')
weld.Part1=character_instances
weld.C1=CFrame.new(0,0,5)
debris:AddItem(weld,.05)
end
end
task.wait(.1)
--ragdolls the opponent--
for _,root_part in opponent_character do
if root_part.Name=='HumanoidRootPart' then
root_part.CFrame=CFrame.lookAt(root_part.CFrame.Position,character:FindFirstChild('HumanoidRootPart').CFrame.Position)
character:FindFirstChild('HumanoidRootPart').CFrame=CFrame.lookAt(character:FindFirstChild('HumanoidRootPart').CFrame.Position,root_part.CFrame.Position)
local attachment_0=Instance.new('Attachment',root_part)
local linear_velocity=Instance.new('LinearVelocity',root_part)
linear_velocity.Attachment0=attachment_0
linear_velocity.MaxForce=math.huge
linear_velocity.VectorVelocity=root_part.CFrame.LookVector*-500+root_part.CFrame.UpVector*200-ragdoll force
for _,joint in opponent_character do
if joint:IsA('Motor6D') then
joint.Enabled=false
local socket=Instance.new('BallSocketConstraint',joint.Parent)
local attachment_1=Instance.new('Attachment',joint.Part0)
local attachment_2=Instance.new('Attachment',joint.Part1)
linear_velocity.MaxForce=math.huge
attachment_1.CFrame=joint.C0
attachment_2.CFrame=joint.C1
socket.Attachment0=attachment_1
socket.Attachment1=attachment_2
socket.LimitsEnabled=true
socket.TwistLimitsEnabled=true
debris:AddItem(attachment_0,.5)
debris:AddItem(linear_velocity,.5)
debris:AddItem(socket,2.5)
end
end
end
end
task.wait(2)
--resets the opponent--
for _,character_instances in opponent_character do
if character_instances:IsA('BasePart') then
if character_instances.Name=='HumanoidRootPart' then character_instances.Anchored=false end
character_instances.Massless=false
--character_instances.CollisionGroupId=0
end
if character_instances:IsA('Motor6D') then
character_instances.Enabled=true
end
if character_instances.Name=="Humanoid" then
character_instances.PlatformStand=false
character_instances:ChangeState(Enum.HumanoidStateType.GettingUp)
end
end
return
end
Any help would be appreciated!