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

Why is hit a nil value in this script?

Asked by 9 years ago
--BaseBall Bat script made by Cyotokatrov.
script.Parent.Equipped:connect(function(m)
        m.Button1Down:connect(function(hit)
            script.Parent.Parent.SmackAnim.Disabled = false
            if game.Players.LocalPlayer.PlayerGui.StrengthGui.Strength == 20 then
                script.Parent.HittingPart.Damage.MinValue = script.Parent.HittingPart.Damage.MinValue + 20
                script.Parent.HittingPart.Damage.Value = script.Parent.HittingPart.Damage.Value + 20
            end
            if game.Players.LocalPlayer.PlayerGui.StrengthGui.Strength == 40 then
                script.Parent.HittingPart.Damage.MinValue = script.Parent.HittingPart.Damage.MinValue + 40
                script.Parent.HittingPart.Damage.Value = script.Parent.HittingPart.Damage.Value + 40
            end
            if game.Players.LocalPlayer.PlayerGui.StrengthGui.Strength == 60 then
                script.Parent.HittingPart.Damage.MinValue = script.Parent.HittingPart.Damage.MinValue + 60
                script.Parent.HittingPart.Damage.Value = script.Parent.HittingPart.Damage.Value + 60 --capped at right here anything else is too OP. this is OP enough.
                local x = math.random(1,1000)
                if x > 500 and hit.Parent.Humanoid then
                    print("SOMEONE BOUT TO GET POPPED ROUND HERE")
                    script.Parent.Handle.Yell3:Play()
                    hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 70
                    hit:GetPlayerFromCharacter(hit).PlayerGui.UnconsciousGui.TextLabel.Visible = true
                end
            end
            hit.Parent.Humanoid.Health = hit.Humanoid.Health - script.Parent.HittingPart.Damage.Value
    end)
end)

--gripright is -1
--0.317, 0.632, -0.707 for gripforward

Everything's working smoothly except for my hit function. Why is that?

Answer this question