-
I Have ragdoll system, which is based on the player hitting the R button, I need to switch this to a system which activates based on death but also if the players health is below 20 and also it should be able to unragdoll the player.
-
It works with r15, but does not work with r6.
-
I put the triggers inside the script, and modified the ragdoll() function, it works with r15 but doesnt work with r6 like ive said. Yes it does work in its original form.
The original script:
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character
local Humanoid = Character:FindFirstChild("Humanoid")
local Mouse = Player:GetMouse()
local RagdollRemote = Player:WaitForChild("RagdollRemote")
local Enabled = true
Input = (game:FindService("ContextActionService") or game:GetService("ContextActionService"))
function Ragdoll(actionName, inputState, inputObj)
if inputState == Enum.UserInputState.Begin then
if not Enabled then return end
Enabled = false
RagdollRemote:FireServer(true)
wait(1)
Enabled = true
end
end
Input:BindAction("RagdollButton",Ragdoll,true,Enum.KeyCode.R,Enum.KeyCode.ButtonY)
Input:SetTitle("RagdollButton", "Rag")
Input:SetPosition("RagdollButton",UDim2.new(.5,0,0,0))
Humanoid.StateChanged:Connect(function(old, new)
if new == Enum.HumanoidStateType.Physics or new == Enum.HumanoidStateType.FallingDown then
RagdollRemote:FireServer(false, true)
elseif (old == Enum.HumanoidStateType.Physics or old == Enum.HumanoidStateType.FallingDown) and (new ~= Enum.HumanoidStateType.Physics and new ~= Enum.HumanoidStateType.FallingDown) then
RagdollRemote:FireServer(false, false)
end
end)
game["Run Service"].RenderStepped:Connect(function()
if Humanoid:GetState() == Enum.HumanoidStateType.Physics then
local AnimationTracks = Humanoid:GetPlayingAnimationTracks()
-- Stop all playing animations
for i, track in pairs (AnimationTracks) do
track:Stop()
end
end
end)
My modified version:
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character
local Humanoid = Character:FindFirstChild("Humanoid")
local Mouse = Player:GetMouse()
local RagdollRemote = Player:WaitForChild("RagdollRemote")
local Enabled = true
Input = (game:FindService("ContextActionService") or game:GetService("ContextActionService"))
function Ragdoll(actionName, inputState, inputObj)
if not Enabled then return end
Enabled = false
RagdollRemote:FireServer(true)
wait(1)
Enabled = true
end
Humanoid.HealthChanged:connect(function()
if Humanoid.Health <= 20 then
Ragdoll()
wait(8)
Ragdoll()
end
end)
Humanoid.Died:connect(function()
Ragdoll()
end)
Humanoid.StateChanged:Connect(function(old, new)
if new == Enum.HumanoidStateType.Physics or new == Enum.HumanoidStateType.FallingDown then
RagdollRemote:FireServer(false, true)
elseif (old == Enum.HumanoidStateType.Physics or old == Enum.HumanoidStateType.FallingDown) and (new ~= Enum.HumanoidStateType.Physics and new ~= Enum.HumanoidStateType.FallingDown) then
RagdollRemote:FireServer(false, false)
end
end)
game["Run Service"].RenderStepped:Connect(function()
if Humanoid:GetState() == Enum.HumanoidStateType.Physics then
local AnimationTracks = Humanoid:GetPlayingAnimationTracks()
-- Stop all playing animations
for i, track in pairs (AnimationTracks) do
track:Stop()
end
end
end)