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

Bool Values not working even after being in starter character and a dummy?

Asked by 3 years ago
        HitBox.Touched:Connect(function(Hit)
        if Hit.Parent == Char or Hit.Parent.Parent == Char then return end
        if Hit.Parent ~= Char or Hit.Parent.Parent ~= Char then
            local Humanoid = Hit.Parent:FindFirstChild("Humanoid") or Hit.Parent.Parent:FindFirstChild("Humanoid")
                if Humanoid and cool == false and Humanoid.Health > 0 then 
                    cool = true
                    if Humanoid:FindFirstChild("PlayerConditions")['Blocking'].Value == true then return end
                    if Humanoid:FindFirstChild("Blocking")['Blocking'].Value == true then
                    local BeingHit = Humanoid.Parent:FindFirstChild("PlayerConditions")['IsBeingHit']
                    if BeingHit and BeingHit.Value == false then    
                        BeingHit.Value = true
                        local S = Instance.new("Sound", Humanoid) 
                        S.SoundId = "rbxassetid://566593606"
                        S.PlaybackSpeed = math.random(80,120)/100
                        S:Play()
                        local Track = Instance.new("Animation")
                        Track.AnimationId = "rbxassetid://5849561534"
                        local Anim = Humanoid:LoadAnimation(Track)
                        Anim:Play()
                        FX.Parent = workspace
                        FX.CFrame = Humanoid.Parent.HumanoidRootPart.CFrame*CFrame.new(math.random(-10,5)/15,math.random(-10,5)/15,math.random(-10,5)/15)
                        Humanoid:TakeDamage(7.5)
                        Stun(Humanoid)
                        wait(.35)
                        FX.Parent = nil
                        BeingHit.Value = false
                        cool = false
                    end
                end
                    game.Debris:AddItem(HitBox, .13)
                end
            end
        end)
    end
end)

This is the code I have for the Hitbox I am scripting for a combat system, and Im trying to get it so it does not do any damage or anything if the person is blocking. However, it keeps saying that there is an "attempt to index nil with 'Blocking'." This doesn't make any sense considering there are other areas in the script where the bool value has worked.

0
can you please state which line the error is coming from? kazor64ti 0 — 3y
0
The error is coming from line 7 Eisphere 0 — 3y
0
The "cool" variable is still probably set to true once you target a blocking dummy (if I understood correctly.) Try adding an else condition for your if condition at line 5. Y_VRN 246 — 3y

Answer this question