Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Child is not a valid member of character after they die?

Asked by 2 years ago

I have this here script that is supposed to grab players when the vampire player touches them while in beast mode. But the problem is that when a player dies (grabbed player or vampire player) the script starts bugging out and saying that the child of the character is not valid. Any way to work around this?

pictures of errors

local grabblock = script.Parent.Torso
local vampchar = script.Parent
local vampplayer = game.Players:GetPlayerFromCharacter(vampchar)
local BeastEvent = game.ReplicatedStorage.Events.BeastMode
local cd = false
local players = game:GetService("Players")
if vampchar.charactervalues:WaitForChild("Role").Value ~= "Vampire" then 
    script.Disabled = true
end
grabblock.Touched:Connect(function(v1)
    local v2 = v1.Parent
    local v3 = players:GetPlayerFromCharacter(v2)
    if vampchar:FindFirstChild("charactervalues").Grabbing.Value == true then return end
   if v2:FindFirstChild("Humanoid") then
        if vampchar.charactervalues.BeastMode.Value == true and v2.charactervalues.Role.Value ~= "Vampire" and vampchar.charactervalues.Grabbing ~= true and v2.Humanoid.Health ~= 0 and (not v2:FindFirstChild("FF")) and (v2.charactervalues.Grabbed.Value ~=true) then
            if not cd then
                cd = true
                --changing values
        vampchar.Humanoid:LoadAnimation(script.Grab):Play()
                vampchar.charactervalues.Grabbing.Value = true
                --vampchar.charactervalues.GrabbingWho.Value = v2.Name
                v2.charactervalues.Grabbed.Value = true

                --v2.charactervalues.GrabbedBy.Value = vampchar.Name
            --grab jumpscare sound
        local bsound = game.ServerStorage.CaughtSnd:Clone()
        bsound.Parent = vampchar.HumanoidRootPart
        bsound.Playing = true
                spawn(function()
                task.wait(7)
                bsound:Destroy()
                end)
                local screamnum = math.random(1,2)
                if screamnum == 1 then
                    local scream1 = game.ServerStorage.Scream1:Clone()
                    scream1.Parent = v2:FindFirstChild("HumanoidRootPart")
                    scream1.Playing = true
                    spawn(function()
                        task.wait(7)
                        scream1:Destroy()
                    end)
                elseif screamnum == 2 then
                    local scream2 = game.ServerStorage.Scream2:Clone()
                    scream2.Parent = v2:FindFirstChild("HumanoidRootPart")
                    scream2.Playing = true
                    spawn(function()
                        task.wait(7)
                        scream2:Destroy()
                    end)
                end

        local moveto = game.ServerStorage.GrabWeld:Clone()
        moveto.Parent = vampchar
            moveto.Attachment0 = v2.Torso.GrabAttatch
                moveto.Attachment1 = vampchar.Torso.GrabAttatch
            end
            vampchar.charactervalues.BeastMode.Changed:Connect(function()
                if vampchar.charactervalues.BeastMode.Value == false and vampchar.charactervalues.Grabbing.Value == true then
                    v2.charactervalues:WaitForChild("Grabbed").Value = false
                    --v2.charactervalues:WaitForChild("GrabbedBy").Value = ""
                end
            end)
        wait(5)
        cd = false
        end

        local progress = v2.charactervalues:WaitForChild("EscapeProgress")
        local grabbed = v2.charactervalues:WaitForChild("Grabbed")
        --local grabbedby = v2.charactervalues:WaitForChild("GrabbedBy")
        local grabbing = vampchar.charactervalues:WaitForChild("Grabbing")
        --local grabbingwho = vampchar.charactervalues:WaitForChild("GrabbingWho")
        local beast = vampchar.charactervalues:WaitForChild("BeastMode")
        local anim = v2.Humanoid:LoadAnimation(script.Escape)
        progress.Changed:Connect(function()
            if progress.Value == 100 and grabbed.Value == true then
                anim:Play()
                local ff = Instance.new("ForceField")
                ff.Name = "FF"
                ff.Parent = v2
                spawn(function()
                    wait(1)
                    ff:Destroy()
                end)
                beast.Value = false
                progress.Value = 0
                grabbing.Value = false
                --grabbingwho.Value = ""
                grabbed.Value = false
                --grabbedby.Value = ""
                vampchar.Head.face.Transparency = 0
                vampchar.Head.Decal.Transparency = 1
                vampchar:WaitForChild("Humanoid:").PlatformStand = true
            end
            spawn(function()
                wait(2)
                vampchar:WaitForChild("Humanoid:").PlatformStand = false
            end)
        end)


        --[[
        vampchar.BeastMode.Changed:Connect(function()
            if vampchar.BeastMode.Value == false and grabbedchar.Parent:FindFirstChild("Grabbed").Value == true then
                grabbedchar.Parent.Grabbed.Value = false
                grabbedchar.Parent.GrabbedBy.Value = ""
            end
        end)
        ]]

        local humanoidvamp = vampchar:WaitForChild("Humanoid")
        local hymanoid = v2:WaitForChild("Humanoid")
        local vampvalues = vampchar:WaitForChild("charactervalues")
            v2.Humanoid.Died:Connect(function()
            if vampvalues.Role.Value ~= "Vampire" then return end
            vampvalues.BeastMode.Value = false
            vampvalues.Grabbing.Value = false
                --  vampchar.charactervalues.GrabbingWho.Value = ""
                vampchar.Head.face.Transparency = 0
                vampchar.Head.Decal.Transparency = 1
                humanoidvamp.WalkSpeed = 16
        end)

            v2.Humanoid.HealthChanged:Connect(function()
            if v2.Humanoid.Health <10 and vampchar.charactervalues.Infect.Value == true and v2.charactervalues.Role.Value == "Survivor" and v2.charactervalues.Grabbed.Value == true and vampchar.charactervalues.Grabbing.Value == true then
                    print("bruh")
                        vampchar.charactervalues.Infect.Value = false
                        beast.Value = false
                        progress.Value = 0
                        grabbing.Value = false
                        --grabbingwho.Value = ""
                grabbed.Value = false
                v2.charactervalues.Infect.Value = false
                        --grabbedby.Value = ""
                        vampchar.Head.face.Transparency = 0
                        vampchar.Head.Decal.Transparency = 1
                        hymanoid.PlatformStand = true
                v2.charactervalues.Role.Value = "Vampire"
                v2.Humanoid.Health = v2.Humanoid.MaxHealth
                game.ServerStorage.Transformed:Clone().Parent = v3.PlayerGui
                spawn(function()
                            wait(2)
                    hymanoid.PlatformStand = false
                    end)

                end
            end)




end
end)
1
check if the character is alive or not then continue Puppynniko 1059 — 2y
0
when i try to check the humanoids health it pops up the same "humanoid is not a valid member of character" Uniplier 83 — 2y
0
it might be the ragdoll script im using. Uniplier 83 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago

There was a ragdoll script that i was using that deleted the character's humanoid on death. I removed the script and will now look for a different one or make my own.

Ad

Answer this question