Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0301· openaiHugging Face Suzhen/CodeChat

hey! i need you to help me with a roblox r6 ragdoll system that only triggers with a…

  1. User

    hey! i need you to help me with a roblox r6 ragdoll system that only triggers with a remote event, so i got this script in serverscriptservice:

    local ragdollEvent = Instance.new("RemoteEvent") ragdollEvent.Name = "RagdollEvent" ragdollEvent.Parent = game:GetService("ReplicatedStorage")

    local function ragdollPlayer(player) local character = player.Character or player.CharacterAdded:Wait() local humanoid = character:FindFirstChildOfClass("Humanoid") local ragdoll = Instance.new("Model") ragdoll.Name = "Ragdoll" ragdoll.Parent = humanoid

    if humanoid.RigType == Enum.HumanoidRigType.R6 then
    	local ragdoll = humanoid:FindFirstChild("Ragdoll")
    	local torso = character:FindFirstChild("Torso") or character:FindFirstChild("UpperTorso")
    
    	if not ragdoll then
    		print("Ragdoll object not found in humanoid.")
    		return
    	elseif character:FindFirstChild("Ragdoll") then
    		print("Character is already ragdolled.")
    		return
    	end
    
    	-- Create a new humanoid object
    	local newHumanoid = Instance.new("Humanoid")
    	newHumanoid.Name = "Humanoid"
    	newHumanoid.Health = humanoid.Health
    	newHumanoid.MaxHealth = humanoid.MaxHealth
    	newHumanoid.WalkSpeed = humanoid.WalkSpeed
    	newHumanoid.JumpPower = humanoid.JumpPower
    	newHumanoid.MoveTo = humanoid.MoveTo
    	newHumanoid.AutoRotate = humanoid.AutoRotate
    	newHumanoid.Team = humanoid.Team
    	newHumanoid.PlatformStand = humanoid.PlatformStand
    	newHumanoid.RootPart = humanoid.RootPart
    	local rootPart = character:FindFirstChild("HumanoidRootPart") or character:FindFirstChild("LowerTorso")
    	rootPart.Velocity = humanoid.RootPart.Velocity
    
    	humanoid:Destroy()
    	ragdoll:Clone().Parent = character
    
    	torso.Anchored = true
    	wait(2)
    	torso.Anchored = false
    
    	newHumanoid.Parent = character
    else
    	print("Character is not an R6 model.")
    end
    

    end

    ragdollEvent.OnServerEvent:Connect(function(player) ragdollPlayer(player) end)

    i already tested it and it gave me this problem: "MoveTo is not a valid member of Humanoid "Humanoid""

  2. Assistant

    The error message "MoveTo is not a valid member of Humanoid 'Humanoid'" is raised because MoveTo is not a valid member of the Humanoid class in Roblox.

    To fix this issue, remove the following line from the code:

    newHumanoid.MoveTo = humanoid.MoveTo

    The MoveTo property is not needed for the ragdoll system, so removing this line should not cause any problems.

  3. User

    now it gave me this problem: "Team is not a valid member of Humanoid "Workspace.Skordsar.Humanoid""

  4. Assistant

    The error message "Team is not a valid member of Humanoid 'Workspace.Skordsar.Humanoid'" is raised because Team is not a property of the Humanoid class. Instead, Team is a property of the Player object.

    In the script, you are trying to copy the Team value from the original humanoid object to the new one. To fix this issue, you need to copy the Team value from the player object instead.

    Replace the following line of code:

    newHumanoid.Team = humanoid.Team

    With this line:

    newHumanoid.Team = player.Team

    This should resolve the issue.

  5. User

    it still gives me the same issue

  6. Assistant

    If you're still getting the same issue after making the suggested change, it's possible that the error is occurring somewhere else in the code.

    Another potential issue could be the fact that the Team property is a datatype of type Enumeration/Team, and not just a number. It needs to be specifically set to an existing team by name. So, you can try the following code instead:

    newHumanoid.Team = player.Team.Name

    If the issue persists, please provide me with the full error message and any other relevant information to help me better understand the issue.

  7. User

    i deleted that line code and it gave me this error "Unable to assign property RootPart. Property is read only"

  8. Assistant

    The error message "Unable to assign property RootPart. Property is read only" is raised because the RootPart property of a Humanoid is read-only and cannot be assigned.

    In the script, you are trying to assign the RootPart property of the new Humanoid to the RootPart property of the original Humanoid. To fix this issue, remove the following line of code:

    newHumanoid.RootPart = humanoid.RootPart

    This line is unnecessary and is causing the error. The new Humanoid will automatically have a RootPart assigned to it based on the character's model, so there's no need to assign it manually.

  9. User

    so i am supposing that happens with every single one right?

  10. Assistant

    In general, yes. In the script, any property or method that is read-only or not valid for the Humanoid class will cause an error if you try to assign it or access it in that way.

    It's important to read through the error messages to determine which property or method is causing the issue and then look up the documentation for that property or method to see if there are any restrictions or limitations that you need to be aware of.

  11. User

    alright, so i deleted the whole arguments about it, now im left with this:

    local ragdollEvent = Instance.new("RemoteEvent") ragdollEvent.Name = "RagdollEvent" ragdollEvent.Parent = game:GetService("ReplicatedStorage")

    local function ragdollPlayer(player) local character = player.Character or player.CharacterAdded:Wait() local humanoid = character:FindFirstChildOfClass("Humanoid") local ragdoll = Instance.new("Model") ragdoll.Name = "Ragdoll" ragdoll.Parent = humanoid

    if humanoid.RigType == Enum.HumanoidRigType.R6 then
    	local ragdoll = humanoid:FindFirstChild("Ragdoll")
    	local torso = character:FindFirstChild("Torso") or character:FindFirstChild("UpperTorso")
    
    	if not ragdoll then
    		print("Ragdoll object not found in humanoid.")
    		return
    	elseif character:FindFirstChild("Ragdoll") then
    		print("Character is already ragdolled.")
    		return
    	end
    	
    	
    	local rootPart = character:FindFirstChild("HumanoidRootPart") or character:FindFirstChild("LowerTorso")
    	rootPart.Velocity = humanoid.RootPart.Velocity
    
    	humanoid:Destroy()
    	ragdoll:Clone().Parent = character
    
    	torso.Anchored = true
    	wait(2)
    	torso.Anchored = false
    	
    else
    	print("Character is not an R6 model.")
    end
    

    end

    ragdollEvent.OnServerEvent:Connect(function(player) ragdollPlayer(player) end)

    after testing this script, my avatar would just froze mid air, aswell my camera would freeze and i wouldnt respawn nor reset my characted, how do i solve that?

  12. Assistant

    The issue you're experiencing where your character freezes and becomes unresponsive is likely caused by the fact that you're destroying the Humanoid object. Once the Humanoid object is destroyed, your character will no longer have any of its normal movement or animation controls.

    To fix this issue, instead of destroying the Humanoid object, you can set its Health property to 0. This will cause the character to appear as if it's been ragdolled without actually destroying the Humanoid object.

    Replace the following line of code:

    humanoid:Destroy()

    With this line:

    humanoid.Health = 0

    This should allow you to ragdoll your character without causing it to freeze or become unresponsive.

  13. User

    well, guess my character dies literally, every part of it just goes away like some bricks

  14. Assistant

    I apologize for my previous recommendation, the "humanoid.Health = 0" will indeed destroy the character's model.

    To ragdoll the character without destroying it, you can use the :Replace method to replace the R6 Humanoid with an R15 Humanoid, which will ragdoll the character without destroying it.

    Here's the updated code:

    local ragdollEvent = Instance.new("RemoteEvent")
    ragdollEvent.Name = "RagdollEvent"
    ragdollEvent.Parent = game:GetService("ReplicatedStorage")
    
    local function ragdollPlayer(player)
        local character = player.Character or player.CharacterAdded:Wait()
        local humanoid = character:FindFirstChildOfClass("Humanoid")
        
        if humanoid.RigType == Enum.HumanoidRigType.R6 then
            local humanoidRootPart = character:FindFirstChild("HumanoidRootPart") or character:FindFirstChild("LowerTorso")
            local rootJoint = humanoidRootPart.RootJoint
            local ragdoll = Instance.new("Model")
            ragdoll.Name = "Ragdoll"
            ragdoll.Parent = humanoidRootPart
            
            humanoid:Replace()
            humanoidRootPart.RigType = Enum.HumanoidRigType.R15
            
            ragdoll:Clone().Parent = humanoidRootPart
            
            humanoidRootPart.RootJoint.C0 = rootJoint.C0
            humanoidRootPart.RootJoint.C1 = rootJoint.C1
            
            local torso = character:FindFirstChild("Torso") or character:FindFirstChild("UpperTorso")
            torso.Anchored = true
            
            wait(2)
            torso.Anchored = false
        else
            print("Character is not an R6 model.")
        end
    end
    
    ragdollEvent.OnServerEvent:Connect(function(player)
        ragdollPlayer(player)
    end)
    

    This solution replaces the existing R6 Humanoid with a new R15 Humanoid, which should ragdoll the character without destroying it. Please let me know if this helps resolve the issue.

  15. User

    im using a r6 game, not r15

  16. Assistant

    I see, I apologize for the confusion. In that case, you can do the following changes in the code:

    1. Instead of destroying the humanoid, you can set its HipHeight property to a value greater than 0. This will cause the character to fall and look like it's been ragdolled without actually being destroyed.

    2. Instead of creating a new humanoid, you can clone the existing humanoid and modify its properties to create the ragdoll.

    Here's the updated code:

    local ragdollEvent = Instance.new("RemoteEvent")
    ragdollEvent.Name = "RagdollEvent"
    ragdollEvent.Parent = game:GetService("ReplicatedStorage")
    
    local function ragdollPlayer(player)
        local character = player.Character or player.CharacterAdded:Wait()
        local humanoid = character:FindFirstChildOfClass("Humanoid")
        local ragdoll = Instance.new("Model")
        ragdoll.Name = "Ragdoll"
        ragdoll.Parent = character
        
        if humanoid.RigType == Enum.HumanoidRigType.R6 then
            local hips = character:FindFirstChild("HumanoidRootPart") or character:FindFirstChild("LowerTorso")
            local newHumanoid = humanoid:Clone()
            newHumanoid.Name = "RagdollHumanoid"
            newHumanoid.Parent = character
            
            hips.Anchored = true
            humanoid.HipHeight = humanoid.HipHeight + 10 -- Raise the hips to make the character fall
            
            humanoid.PlatformStand = true  -- Make the character not stand up on its own
            
            humanoid.WalkSpeed = 0  -- Disable character's movement
            humanoid.JumpPower = 0  -- Disable character's movement
    
            humanoid:ChangeState(Enum.HumanoidStateType.Physics)
            humanoid:Move(character.PrimaryPart.Position - Vector3.new(0,0.5,0))
    
            local torso = character:FindFirstChild("Torso") or character:FindFirstChild("UpperTorso")
            torso.Anchored = true
    
            wait(2)
            humanoid:Move(Vector3.new(0, -10, 0)) -- Make the character fall down
            wait(1)
            
            humanoid:TakeDamage(100) -- Remove the humanoid after the character falls down 
            
            newHumanoid.Name = "Humanoid" -- Restore the original Name of the humanoid
        else
            print("Character is not an R6 model.")
        end
    end
    
    ragdollEvent.OnServerEvent:Connect(function(player)
        ragdollPlayer(player)
    end)
    

    This code clones the existing humanoid, raises the hips to make the character fall, and disables its movement. Then it sets the humanoid state to physics and removes it after the character falls down. Finally, it restores the original Name of the humanoid.

  17. User

    uhh.. it stays mid air for like 2 seconds and it respawns..

  18. Assistant

    I see. This is most likely happening because the character's humanoid is still set to PlatformStand mode, and the character is not falling all the way down to the ground before being respawned.

    You can fix this issue by removing the PlatformStand property of the humanoid, and wait until the character falls all the way down before respawning. Here's the updated code:

    local ragdollEvent = Instance.new("RemoteEvent")
    ragdollEvent.Name = "RagdollEvent"
    ragdollEvent.Parent = game:GetService("ReplicatedStorage")
    
    local function ragdollPlayer(player)
        local character = player.Character or player.CharacterAdded:Wait()
        local humanoid = character:FindFirstChildOfClass("Humanoid")
        local ragdoll = Instance.new("Model")
        ragdoll.Name = "Ragdoll"
        ragdoll.Parent = character
        
        if humanoid.RigType == Enum.HumanoidRigType.R6 then
            local hips = character:FindFirstChild("HumanoidRootPart") or character:FindFirstChild("LowerTorso")
            local newHumanoid = humanoid:Clone()
            newHumanoid.Name = "RagdollHumanoid"
            newHumanoid.Parent = character
            
            hips.Anchored = true
            humanoid.HipHeight = humanoid.HipHeight + 10 -- Raise the hips to make the character fall
            
            humanoid.PlatformStand = true  -- Make the character not stand up on its own
            
            humanoid.WalkSpeed = 0  -- Disable character's movement
            humanoid.JumpPower = 0  -- Disable character's movement
    
            humanoid:ChangeState(Enum.HumanoidStateType.Physics)
            humanoid:Move(character.PrimaryPart.Position - Vector3.new(0,0.5,0))
    
            local torso = character:FindFirstChild("Torso") or character:FindFirstChild("UpperTorso")
            torso.Anchored = true
            
            wait(2)
            humanoid:Move(Vector3.new(0, -100, 0)) -- Make the character fall down
            wait(3)  -- Wait until the character hits the ground
            
            humanoid.PlatformStand = false  -- Remove the PlatformStand property
            player:LoadCharacter()  -- Respawn the character
            
            newHumanoid.Name = "Humanoid" -- Restore the original Name of the humanoid
        else
            print("Character is not an R6 model.")
        end
    end
    
    ragdollEvent.OnServerEvent:Connect(function(player)
        ragdollPlayer(player)
    end)
    

    In this updated code, after making the character fall down, we wait for a few seconds to make sure it hits the ground before respawning it. Also, we remove the PlatformStand property before respawning to ensure that the character can move normally upon respawn.

  19. User

    i think you dont understand me, apologies for not bringing enough information

  20. Assistant

    I apologize for any confusion. Can you please provide more information about the issue you're experiencing? That will help me better understand the problem and provide an appropriate solution.