Hey there,
I’m trying to fix an issue when a character hit’s a part I don’t want the walking animation to play which is weird I just simply want to ragdoll the character and then after a few seconds it recovers back to it’s normal state.
The issue that I have right now is that the for some reason when the character get’s ragdolled after hitting a part, it plays the walking animation which doesn’t happen when you ragdoll your character via a button it ragdolls your character normally, but when the character hits a part it does ragdoll but a walking animation plays which I don’t really get why it doesn’t happen when the ragdoll function is enabled from a button.
I’m using a Ragdoll module from:
I’ll post a video for more reference and the code I’m using.
Server
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvents = ReplicatedStorage.Events.RemoteEvents
local RagdollModule = require(game.ReplicatedStorage.Modules.Ragdoll)
local part = script.Parent
local debounce = {}
part.Touched:Connect(function(hit)
if table.find(debounce, hit.Parent) then return end
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid then
local player = Players:GetPlayerFromCharacter(hit.Parent)
if player then
part.Color = Color3.fromRGB(255, 49, 34)
humanoid.WalkSpeed = 0
humanoid.JumpPower = 0
RemoteEvents.Ragdoll:FireClient(player)
table.insert(debounce, hit.Parent)
RagdollModule.Ragdoll(player.Character)
print(hit.Parent)
task.wait(5)
part.Color = Color3.fromRGB(163, 162, 165)
RemoteEvents.Recover:FireClient(player)
table.remove(debounce, table.find(debounce, hit.Parent))
RagdollModule.Recover(player.Character)
end
end
end)
Client
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SoundService = game:GetService("SoundService")
local RemoteEvents = ReplicatedStorage.Events.RemoteEvents
local RemoteFunctions = ReplicatedStorage.Events.RemoteFunctions
local player = Players.LocalPlayer
local playerGui = player.PlayerGui
local playerInfo = playerGui.PlayerInfo.WIP
local imageButton = playerInfo.ImageButton
local resetButton = playerInfo.ResetButton
RemoteEvents.Ragdoll.OnClientEvent:Connect(function()
player.Character.Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
SoundService.Sound:Play()
end)
RemoteEvents.Recover.OnClientEvent:Connect(function()
player.Character.Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
SoundService.Sound:Play()
end)
imageButton.MouseButton1Click:Connect(function()
player.Character.Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
ReplicatedStorage.Events.RemoteEvents.Ragdoll:FireServer(player)
SoundService.Sound:Play()
end)
imageButton.MouseButton2Click:Connect(function()
player.Character.Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
ReplicatedStorage.Events.RemoteEvents.Recover:FireServer(player)
end)
resetButton.MouseButton1Click:Connect(function()
player.Character.Humanoid.Health = 0
player.Character.Humanoid:ChangeState(Enum.HumanoidStateType.Dead)
ReplicatedStorage.Events.RemoteEvents.Dead:FireServer(player)
end)